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 = ();
19 fn from_str(s: &str) -> Result<Self, Self::Err> {
20 <Self as crate::FromCode>::from_code(s).ok_or(())
21 }
22}
23
24impl crate::Code for FiscalID {
25 fn code(self) -> &'static str {
26 match self {
27 FiscalID::FiscalNumber => "FC",
28 }
29 }
30}
31
32impl crate::Description for FiscalID {
33 fn description(self) -> &'static str {
34 match self {
35 FiscalID::FiscalNumber => "Fiscal number",
36 }
37 }
38}
39
40impl crate::FromCode for FiscalID {
41 fn from_code(code: &str) -> Option<Self>
42 where
43 Self: Sized,
44 {
45 match code {
46 "FC" => Some(FiscalID::FiscalNumber),
47 _ => None,
48 }
49 }
50}