1use crate::{Error, ErrorKind, Result};
4use core::{fmt, str::FromStr};
5
6#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
8pub enum TagMode {
9 #[default]
13 Explicit,
14
15 Implicit,
19}
20
21impl FromStr for TagMode {
22 type Err = Error;
23
24 fn from_str(s: &str) -> Result<Self> {
25 match s {
26 "EXPLICIT" | "explicit" => Ok(TagMode::Explicit),
27 "IMPLICIT" | "implicit" => Ok(TagMode::Implicit),
28 _ => Err(ErrorKind::TagModeUnknown.into()),
29 }
30 }
31}
32
33impl fmt::Display for TagMode {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 match self {
36 TagMode::Explicit => f.write_str("EXPLICIT"),
37 TagMode::Implicit => f.write_str("IMPLICIT"),
38 }
39 }
40}