use std::fmt;
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash)]
#[non_exhaustive]
pub enum Digest {
Md5,
Sha1,
#[default]
Sha256,
Sha384,
Sha512,
}
impl AsRef<str> for Digest {
fn as_ref(&self) -> &str {
match self {
Self::Md5 => "md5",
Self::Sha1 => "sha1",
Self::Sha256 => "sha256",
Self::Sha384 => "sha384",
Self::Sha512 => "sha512",
}
}
}
impl fmt::Display for Digest {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(self.as_ref())
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[non_exhaustive]
pub enum JpLevel {
Low,
Medium,
High,
}
impl AsRef<str> for JpLevel {
fn as_ref(&self) -> &str {
match self {
Self::Low => "low",
Self::Medium => "medium",
Self::High => "high",
}
}
}
impl fmt::Display for JpLevel {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(self.as_ref())
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub struct LeafHash<'a> {
pub digest: Digest,
pub hex: &'a str,
}
impl fmt::Display for LeafHash<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "{}:{}", self.digest, self.hex)
}
}