1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
use std::io;

/// An error that occurred during reading.
#[derive(Debug, thiserror::Error)]
pub enum ReadError {
    #[error("failed reading data from reader")]
    Io(#[from] io::Error),
    #[error("failed deserializing JSON")]
    Deserialize(#[from] serde_json::Error),
    #[error("reader has reached EOF")]
    Eof,
}

/// An error that occurred during writing.
#[derive(Debug, thiserror::Error)]
pub enum WriteError {
    #[error("failed writing data to writer")]
    Io(#[from] io::Error),
    #[error("failed serializing JSON")]
    Serialize(#[from] serde_json::Error),
}