use core::fmt::{self, Display, Formatter};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum GuidFromStrError {
Length,
Separator(u8),
Hex(u8),
}
impl Default for GuidFromStrError {
fn default() -> Self {
Self::Length
}
}
impl Display for GuidFromStrError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::Length => {
f.write_str("GUID string has wrong length (expected 36 bytes)")
}
Self::Separator(index) => write!(
f,
"GUID string is missing a separator (`-`) at index {}",
index,
),
Self::Hex(index) => {
write!(
f,
"GUID string contains invalid ASCII hex at index {}",
index,
)
}
}
}
}