Compare commits
2 Commits
ebf1a7726e
...
7828d7c703
Author | SHA1 | Date | |
---|---|---|---|
|
7828d7c703 | ||
|
67486f0042 |
24
src/tags.rs
24
src/tags.rs
@ -3,13 +3,19 @@ use std::fmt;
|
|||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct ImageDetails {
|
struct ImageDetails {
|
||||||
architecture: String,
|
architecture: String,
|
||||||
os: String,
|
// os: String,
|
||||||
size: usize,
|
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)]
|
#[derive(Deserialize)]
|
||||||
pub struct Images {
|
pub struct Images {
|
||||||
images: Vec<ImageDetails>,
|
images: Vec<ImageDetails>,
|
||||||
@ -117,10 +123,22 @@ impl Tags {
|
|||||||
|
|
||||||
impl fmt::Display for Images {
|
impl fmt::Display for Images {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
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 now = chrono::Utc::now();
|
||||||
let rfc3339 = DateTime::parse_from_rfc3339(&self.last_updated).unwrap();
|
let rfc3339 = DateTime::parse_from_rfc3339(&self.last_updated).unwrap();
|
||||||
let dif = now - rfc3339.with_timezone(&chrono::Utc);
|
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
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ impl TagList {
|
|||||||
match &self.typ {
|
match &self.typ {
|
||||||
Type::Status(_) => (),
|
Type::Status(_) => (),
|
||||||
Type::Repo(tags) => match tags.next_page() {
|
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),
|
Ok(tags) => self.typ = Type::Repo(tags),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ impl TagList {
|
|||||||
match &self.typ {
|
match &self.typ {
|
||||||
Type::Status(_) => (),
|
Type::Status(_) => (),
|
||||||
Type::Repo(tags) => match tags.prev_page() {
|
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),
|
Ok(tags) => self.typ = Type::Repo(tags),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user