lox_io/ndm/kvn/
deserializer.rs1use nom::error::ErrorKind;
6
7pub trait KvnDeserializer {
8 fn deserialize<'a>(
9 lines: &mut std::iter::Peekable<impl Iterator<Item = &'a str>>,
10 ) -> Result<Self, KvnDeserializerErr<String>>
11 where
12 Self: Sized;
13
14 fn from_kvn_str(kvn: &str) -> Result<Self, KvnDeserializerErr<String>>
15 where
16 Self: Sized,
17 {
18 Self::deserialize(&mut kvn.lines().peekable())
19 }
20
21 fn should_check_key_match() -> bool;
22}
23
24#[derive(PartialEq, Clone, thiserror::Error, Debug)]
25pub enum KvnDeserializerErr<I> {
26 InvalidDateTimeFormat { input: I },
27 InvalidNumberFormat { input: I },
28 InvalidStringFormat { input: I },
29 InvalidStateVectorFormat { input: I },
30 InvalidCovarianceMatrixFormat { input: I },
31 KeywordNotFound { expected: I },
32 UnexpectedKeyword { found: I, expected: I },
34 EmptyKeyword { input: I },
35 EmptyValue { input: I },
36 UnexpectedEndOfInput { keyword: I },
37 GeneralParserError(I, ErrorKind),
38}