Skip to main content

xrl/protocol/
errors.rs

1use serde_json::error::Category;
2use serde_json::error::Error as SerdeError;
3use std::io;
4
5#[derive(Debug)]
6pub enum DecodeError {
7    Truncated,
8    Io(io::Error),
9    InvalidJson,
10}
11
12impl From<SerdeError> for DecodeError {
13    fn from(err: SerdeError) -> DecodeError {
14        match err.classify() {
15            Category::Io => DecodeError::Io(err.into()),
16            Category::Eof => DecodeError::Truncated,
17            Category::Data | Category::Syntax => DecodeError::InvalidJson,
18        }
19    }
20}
21
22#[derive(Debug)]
23pub enum RpcError {
24    ResponseCanceled,
25    AckCanceled,
26}