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