Skip to main content

tsp_sdk/cesr/
error.rs

1/// An error type to indicate something went wrong with encoding
2#[derive(Clone, Copy, Debug)]
3pub enum EncodeError {
4    ExcessiveFieldSize,
5    MissingHops,
6}
7
8/// An error type to indicate something went wrong with decoding
9#[derive(Clone, Copy, Debug)]
10pub enum DecodeError {
11    UnexpectedData,
12    UnexpectedMsgType,
13    TrailingGarbage,
14    SignatureError,
15    VidError,
16    VersionMismatch,
17    InvalidCryptoType,
18    InvalidSignatureType,
19}
20
21impl std::fmt::Display for EncodeError {
22    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
23        write!(f, "{:?}", self)
24    }
25}
26
27impl std::fmt::Display for DecodeError {
28    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
29        write!(f, "{:?}", self)
30    }
31}
32
33impl std::error::Error for EncodeError {}
34
35impl std::error::Error for DecodeError {}