1use ark_std::{fmt, io};
2
3#[derive(Debug)]
5pub enum SerializationError {
6 NotEnoughSpace,
8 InvalidData,
10 UnexpectedFlags,
13 IoError(io::Error),
15}
16
17impl ark_std::error::Error for SerializationError {}
18
19impl From<io::Error> for SerializationError {
20 fn from(e: io::Error) -> Self {
21 Self::IoError(e)
22 }
23}
24
25impl fmt::Display for SerializationError {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
27 match self {
28 Self::NotEnoughSpace => write!(
29 f,
30 "the last byte does not have enough space to encode the extra info bits"
31 ),
32 Self::InvalidData => write!(f, "the input buffer contained invalid data"),
33 Self::UnexpectedFlags => write!(f, "the call expects empty flags"),
34 Self::IoError(err) => write!(f, "I/O error: {err:?}"),
35 }
36 }
37}