use core::fmt;
use core::str::FromStr;
#[derive(Debug, PartialEq, Eq)]
pub enum Error {
InvalidMarker,
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidMarker => f.write_str("invalid marker"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Marker {
Root,
Reply,
}
impl fmt::Display for Marker {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Root => f.write_str("root"),
Self::Reply => f.write_str("reply"),
}
}
}
impl FromStr for Marker {
type Err = Error;
fn from_str(marker: &str) -> Result<Self, Self::Err> {
match marker {
"root" => Ok(Self::Root),
"reply" => Ok(Self::Reply),
_ => Err(Error::InvalidMarker),
}
}
}