1use ark_std::{fmt, io};
23/// This is an error that could occur during serialization
4#[derive(Debug)]
5pub enum SerializationError {
6/// During serialization, we didn't have enough space to write extra info.
7NotEnoughSpace,
8/// During serialization, the data was invalid.
9InvalidData,
10/// During serialization, non-empty flags were given where none were
11 /// expected.
12UnexpectedFlags,
13/// During serialization, we countered an I/O error.
14IoError(io::Error),
15}
1617impl ark_std::error::Error for SerializationError {}
1819impl From<io::Error> for SerializationError {
20fn from(e: io::Error) -> SerializationError {
21 SerializationError::IoError(e)
22 }
23}
2425impl fmt::Display for SerializationError {
26fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
27match 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}