1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub struct Code(String);
8
9impl Code {
10 pub fn new(value: impl Into<String>) -> Self {
12 Self(value.into())
13 }
14
15 pub fn as_str(&self) -> &str {
17 &self.0
18 }
19
20 pub fn is_empty(&self) -> bool {
22 self.0.trim().is_empty()
23 }
24}
25
26impl fmt::Display for Code {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 self.0.fmt(f)
29 }
30}
31
32impl From<&str> for Code {
33 fn from(value: &str) -> Self {
34 Self::new(value)
35 }
36}