use bollard::secret::{ImageInspect, ImageSummary}; pub trait InspectData { fn tags(&self) -> Option>; fn digests(&self) -> Option>; fn url(&self) -> Option; } impl InspectData for ImageInspect { fn tags(&self) -> Option> { self.repo_tags.clone() } fn digests(&self) -> Option> { self.repo_digests.clone() } fn url(&self) -> Option { match &self.config { Some(config) => match &config.labels { Some(labels) => labels.get("org.opencontainers.image.url").cloned(), None => None, }, None => None, } } } impl InspectData for ImageSummary { fn tags(&self) -> Option> { Some(self.repo_tags.clone()) } fn digests(&self) -> Option> { Some(self.repo_digests.clone()) } fn url(&self) -> Option { self.labels.get("org.opencontainers.image.url").cloned() } } impl InspectData for &String { fn tags(&self) -> Option> { self.split('@').next().map(|tag| vec![tag.to_string()]) } fn digests(&self) -> Option> { match self.split_once('@') { Some((reference, digest)) => Some(vec![format!( "{}@{}", reference.split(':').next().unwrap(), digest )]), None => Some(vec![]), } } fn url(&self) -> Option { None } }