use crate::{Error, ErrorKind, Result};
use core::{fmt, str::FromStr};
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
pub enum TagMode {
Explicit,
Implicit,
}
impl Default for TagMode {
fn default() -> TagMode {
TagMode::Explicit
}
}
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"),
}
}
}