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) -> SerializationError {
21 SerializationError::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 SerializationError::NotEnoughSpace => write!(
29 f,
30 "the last byte does not have enough space to encode the extra info bits"
31 ),
32 SerializationError::InvalidData => write!(f, "the input buffer contained invalid data"),
33 SerializationError::UnexpectedFlags => write!(f, "the call expects empty flags"),
34 SerializationError::IoError(err) => write!(f, "I/O error: {:?}", err),
35 }
36 }
37}