zugferd_code_lists/zugferd_2_3_3/
fiscalid.rs1#![allow(non_camel_case_types)]
2
3#[cfg_attr(feature = "specta", derive(specta::Type))]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
6pub enum FiscalID {
7 FiscalNumber,
9}
10
11impl std::fmt::Display for FiscalID {
12 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13 write!(f, "{}", <Self as crate::Code>::code(*self))
14 }
15}
16
17impl std::str::FromStr for FiscalID {
18 type Err = crate::ParseError<Self>;
19 fn from_str(s: &str) -> Result<Self, Self::Err> {
20 <Self as crate::FromCode>::from_code(s)
21 .ok_or_else(|| crate::ParseError::<Self>::new(s.to_owned()))
22 }
23}
24
25impl crate::Code for FiscalID {
26 fn code(self) -> &'static str {
27 match self {
28 FiscalID::FiscalNumber => "FC",
29 }
30 }
31}
32
33impl crate::Description for FiscalID {
34 fn description(self) -> &'static str {
35 match self {
36 FiscalID::FiscalNumber => "Fiscal number",
37 }
38 }
39}
40
41impl crate::FromCode for FiscalID {
42 fn from_code(code: &str) -> Option<Self>
43 where
44 Self: Sized,
45 {
46 match code {
47 "FC" => Some(FiscalID::FiscalNumber),
48 _ => None,
49 }
50 }
51}