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