zugferd_code_lists/
lib.rs1use std::marker::PhantomData;
2
3pub mod zugferd_2_3_2;
4pub mod zugferd_2_3_3;
5pub mod zugferd_2_4;
6
7pub trait Code {
8 fn code(self) -> &'static str;
9}
10
11pub trait Description {
12 fn description(self) -> &'static str;
13}
14
15pub trait FromCode {
16 fn from_code(code: &str) -> Option<Self>
17 where
18 Self: Sized;
19}
20
21#[cfg(test)]
22mod test {
23 #[allow(unused_imports)]
25 use crate::zugferd_2_3_2::Country::Germany as Germany232;
26
27 #[allow(unused_imports)]
28 use crate::zugferd_2_3_3::Country::Germany as Germany233;
29
30 #[allow(unused_imports)]
31 use crate::zugferd_2_4::Country::Germany as Germany24;
32}
33
34#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
35#[error("Found invalid code \"{code}\" while trying to parse {type_name}", type_name=std::any::type_name::<T>())]
36pub struct ParseError<T> {
37 pub code: String,
38 type_: PhantomData<T>,
39}
40
41impl<T> ParseError<T> {
42 pub(crate) fn new(code: String) -> Self {
43 Self {
44 code,
45 type_: PhantomData,
46 }
47 }
48}