json_walker/
lib.rs

1use std::fmt::{Display, Formatter};
2
3pub mod json_walker;
4mod parser_core;
5mod readers;
6mod deserializer;
7
8const NIL: u8 = 0;
9const ROOT: char = '#';
10
11//region error
12#[derive(Debug, PartialEq)]
13pub struct Error {
14    kind: ErrorKind,
15    msg: String,
16}
17
18impl Error {
19    pub fn new_eos() -> Self {
20        Error { kind: ErrorKind::EOS, msg: "End of stream".to_string() }
21    }
22}
23
24#[derive(Debug, PartialEq)]
25pub enum ErrorKind {
26    EOS,
27    Serde,
28    ParseBoolError,
29    ParseIntError,
30    ParseFloatError,
31    WrongDataType,
32    OOPS,
33}
34
35impl Display for Error {
36    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
37        f.write_str(&format!("Deserialization error: {:?}", self))
38    }
39}
40//endregion