use crate::{Error, ErrorKind, Result};
use core::{fmt, str::FromStr};
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
pub enum TagMode {
#[default]
Explicit,
Implicit,
}
impl FromStr for TagMode {
type Err = Error;
fn from_str(s: &str) -> Result<Self> {
match s {
"EXPLICIT" | "explicit" => Ok(TagMode::Explicit),
"IMPLICIT" | "implicit" => Ok(TagMode::Implicit),
_ => Err(ErrorKind::TagModeUnknown.into()),
}
}
}
impl fmt::Display for TagMode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TagMode::Explicit => f.write_str("EXPLICIT"),
TagMode::Implicit => f.write_str("IMPLICIT"),
}
}
}