Compare commits
No commits in common. "ebf1a7726e50422499dc7bd8a5de178836bdeedf" and "063ce06aaadb9a62cf38defb0f80798414e97c50" have entirely different histories.
ebf1a7726e
...
063ce06aaa
11
src/tags.rs
11
src/tags.rs
@ -20,7 +20,6 @@ pub struct Images {
|
|||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Tags {
|
pub struct Tags {
|
||||||
count: usize,
|
|
||||||
#[serde(rename(deserialize = "next"))]
|
#[serde(rename(deserialize = "next"))]
|
||||||
next_page: Option<String>,
|
next_page: Option<String>,
|
||||||
#[serde(rename(deserialize = "previous"))]
|
#[serde(rename(deserialize = "previous"))]
|
||||||
@ -30,14 +29,9 @@ pub struct Tags {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// repo string contains an illegal character
|
|
||||||
InvalidCharacter(char),
|
InvalidCharacter(char),
|
||||||
/// couldn't fetch json with reqwest
|
|
||||||
Fetching(String),
|
Fetching(String),
|
||||||
/// a serde error
|
|
||||||
Converting(String),
|
Converting(String),
|
||||||
/// invalid repos show a valid json with 0 tags
|
|
||||||
NoTagsFound,
|
|
||||||
NoPrevPage,
|
NoPrevPage,
|
||||||
NoNextPage,
|
NoNextPage,
|
||||||
}
|
}
|
||||||
@ -50,7 +44,6 @@ impl fmt::Display for Error {
|
|||||||
Error::Converting(s) => write!(f, "Converting error: {}", s),
|
Error::Converting(s) => write!(f, "Converting error: {}", s),
|
||||||
Error::NoNextPage => write!(f, "No next page available"),
|
Error::NoNextPage => write!(f, "No next page available"),
|
||||||
Error::NoPrevPage => write!(f, "No previous page available"),
|
Error::NoPrevPage => write!(f, "No previous page available"),
|
||||||
Error::NoTagsFound => write!(f, "Given Repo has 0 tags. Is it valid?"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,10 +69,6 @@ impl Tags {
|
|||||||
Err(e) => return Err(Error::Converting(format!("invalid json: {}", e))),
|
Err(e) => return Err(Error::Converting(format!("invalid json: {}", e))),
|
||||||
};
|
};
|
||||||
|
|
||||||
if tags.count == 0 {
|
|
||||||
return Err(Error::NoTagsFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(tags)
|
Ok(tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ impl ServiceSwitcher {
|
|||||||
Self {
|
Self {
|
||||||
list,
|
list,
|
||||||
state: ListState::default(),
|
state: ListState::default(),
|
||||||
regex: Regex::new(r"( *image *): *([^:]*):?([^:]?) *").unwrap(),
|
regex: Regex::new(r"( *image *): *(.*):([.*]??) *").unwrap(),
|
||||||
changed: false,
|
changed: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user