Skip to main content

docker_registry_client/image/image_name/
digest.rs

1#[derive(Debug)]
2pub enum FromStrError {}
3
4#[derive(Debug, PartialEq, Clone, Eq, Hash)]
5pub struct Digest(String);
6
7impl std::fmt::Display for FromStrError {
8    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9        f.write_str("invalid digest")
10    }
11}
12
13impl std::error::Error for FromStrError {}
14
15impl std::fmt::Display for Digest {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        write!(f, "{}", self.0)
18    }
19}
20
21impl std::str::FromStr for Digest {
22    type Err = FromStrError;
23
24    fn from_str(s: &str) -> Result<Self, Self::Err> {
25        Ok(Self(s.to_string()))
26    }
27}