Compare commits

..

2 Commits

Author SHA1 Message Date
Thomas Eppers
7828d7c703 added info of architecture and size of images 2021-09-23 22:48:19 +02:00
Thomas Eppers
67486f0042 removed warnings for unused argument 2021-09-23 22:48:04 +02:00
2 changed files with 23 additions and 5 deletions

View File

@ -3,13 +3,19 @@ use std::fmt;
use chrono::DateTime;
use serde::Deserialize;
#[derive(Deserialize)]
#[derive(Deserialize, Debug)]
struct ImageDetails {
architecture: String,
os: String,
// os: String,
size: usize,
}
impl fmt::Display for ImageDetails {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[{}, {}MB]", self.architecture, self.size / 1024 / 1024)
}
}
#[derive(Deserialize)]
pub struct Images {
images: Vec<ImageDetails>,
@ -117,10 +123,22 @@ impl Tags {
impl fmt::Display for Images {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//architecture infos
let mut arch = String::new();
for image in &self.images {
arch.push_str(&format!("{}", image));
}
let now = chrono::Utc::now();
let rfc3339 = DateTime::parse_from_rfc3339(&self.last_updated).unwrap();
let dif = now - rfc3339.with_timezone(&chrono::Utc);
write!(f, "{} vor {}", self.tag_name, format_time_nice(dif))
write!(
f,
"{} vor {} {}",
self.tag_name,
format_time_nice(dif),
arch
)
}
}

View File

@ -63,7 +63,7 @@ impl TagList {
match &self.typ {
Type::Status(_) => (),
Type::Repo(tags) => match tags.next_page() {
Err(e) => return Err(Error::NoNextPage),
Err(_) => return Err(Error::NoNextPage),
Ok(tags) => self.typ = Type::Repo(tags),
},
}
@ -75,7 +75,7 @@ impl TagList {
match &self.typ {
Type::Status(_) => (),
Type::Repo(tags) => match tags.prev_page() {
Err(e) => return Err(Error::NoPrevPage),
Err(_) => return Err(Error::NoPrevPage),
Ok(tags) => self.typ = Type::Repo(tags),
},
}