zugferd_code_lists/zugferd_2_3_3/
transport.rs

1#![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 TRANSPORT {
7    /// Transport mode not specified
8    ///
9    /// Transport mode has not been specified_x000D_ Notes:_x000D_ 1) This code can be used when the mode is not known or when information on it is not available at the time of issuing the document concerned.
10    TransportModeNotSpecified,
11    /// Maritime transport
12    ///
13    /// Transport of goods and/or persons is by sea.
14    MaritimeTransport,
15    /// Rail transport
16    ///
17    /// Transport of goods and/or persons is by rail.
18    RailTransport,
19    /// Road transport
20    ///
21    /// Transport of goods and/or persons is by road.
22    RoadTransport,
23    /// Air transport
24    ///
25    /// Transport of goods and/or persons is by air.
26    AirTransport,
27    /// Mail
28    ///
29    /// Method to convey goods is by mail_x000D_ Notes:_x000D_ 1) This code is provided for practical reasons, despite the fact that mail is not a genuine mode of transport. In many countries, the value of merchandise exported and imported by mail is considerable, but the exporter or importer concerned would be unable to state by which mode postal items had been conveyed.
30    Mail,
31    /// Multimodal transpo
32    ///
33    /// Method to convey goods and/or persons is by multimodal transport._x000D_ Notes:_x000D_ 1) This code is provided for practical reasons, despite the fact that multimodal transport is not a genuine mode of transport. It can be used when goods are carried by at least two different modes from a place at which the goods are taken in charge by a transport operator to a place designated for delivery, on the basis of one transport contract. (Operations of pick-up and delivery of goods carried out in the performance of a single mode of transport, as defined in such a contract, shall not be considered as multimodal transport).
34    MultimodalTranspo,
35    /// Fixed transport installation
36    ///
37    /// Transport of item is via a fixed transport installation._x000D_ Notes:_x000D_ 1) This code applies to installations for continuous transport such as pipelines, ropeways and electric power lines.
38    FixedTransportInstallation,
39    /// Inland water transport
40    ///
41    /// Transport of goods and/or persons is by inland water.
42    InlandWaterTransport,
43    /// Transport mode not applicable
44    ///
45    /// The mode of transport is not applicable.
46    TransportModeNotApplicable,
47}
48
49impl std::fmt::Display for TRANSPORT {
50    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51        write!(f, "{}", <Self as crate::Code>::code(*self))
52    }
53}
54
55impl std::str::FromStr for TRANSPORT {
56    type Err = crate::ParseError<Self>;
57    fn from_str(s: &str) -> Result<Self, Self::Err> {
58        <Self as crate::FromCode>::from_code(s)
59            .ok_or_else(|| crate::ParseError::<Self>::new(s.to_owned()))
60    }
61}
62
63impl crate::Code for TRANSPORT {
64    fn code(self) -> &'static str {
65        match self {
66            TRANSPORT::TransportModeNotSpecified => "0",
67            TRANSPORT::MaritimeTransport => "1",
68            TRANSPORT::RailTransport => "2",
69            TRANSPORT::RoadTransport => "3",
70            TRANSPORT::AirTransport => "4",
71            TRANSPORT::Mail => "5",
72            TRANSPORT::MultimodalTranspo => "6",
73            TRANSPORT::FixedTransportInstallation => "7",
74            TRANSPORT::InlandWaterTransport => "8",
75            TRANSPORT::TransportModeNotApplicable => "9",
76        }
77    }
78}
79
80impl crate::Description for TRANSPORT {
81    fn description(self) -> &'static str {
82        match self {
83            TRANSPORT::TransportModeNotSpecified => "Transport mode not specified",
84            TRANSPORT::MaritimeTransport => "Maritime transport",
85            TRANSPORT::RailTransport => "Rail transport",
86            TRANSPORT::RoadTransport => "Road transport",
87            TRANSPORT::AirTransport => "Air transport",
88            TRANSPORT::Mail => "Mail",
89            TRANSPORT::MultimodalTranspo => "Multimodal transpo",
90            TRANSPORT::FixedTransportInstallation => "Fixed transport installation",
91            TRANSPORT::InlandWaterTransport => "Inland water transport",
92            TRANSPORT::TransportModeNotApplicable => "Transport mode not applicable",
93        }
94    }
95}
96
97impl crate::FromCode for TRANSPORT {
98    fn from_code(code: &str) -> Option<Self>
99    where
100        Self: Sized,
101    {
102        match code {
103            "0" => Some(TRANSPORT::TransportModeNotSpecified),
104            "1" => Some(TRANSPORT::MaritimeTransport),
105            "2" => Some(TRANSPORT::RailTransport),
106            "3" => Some(TRANSPORT::RoadTransport),
107            "4" => Some(TRANSPORT::AirTransport),
108            "5" => Some(TRANSPORT::Mail),
109            "6" => Some(TRANSPORT::MultimodalTranspo),
110            "7" => Some(TRANSPORT::FixedTransportInstallation),
111            "8" => Some(TRANSPORT::InlandWaterTransport),
112            "9" => Some(TRANSPORT::TransportModeNotApplicable),
113            _ => None,
114        }
115    }
116}