use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum IntegerReadError {
#[error("encountered error while reading byte stream {source}")]
StreamError {
#[from]
source: std::io::Error,
},
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum FloatReadError {
#[error("encountered error while reading byte stream {source}")]
StreamError {
#[from]
source: std::io::Error,
},
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum StringReadError {
#[error("encountered error while reading byte stream {source}")]
LengthReadingError {
#[from]
source: std::io::Error,
},
#[error("encountered error while processing string length {source}")]
LengthParsingError {
#[from]
source: VariableLengthEnumError,
},
#[error("bytes are not valid utf-8 {source}")]
InvalidUtf8 {
#[from]
source: std::string::FromUtf8Error,
},
#[error("string length is too large")]
LengthTooLarge,
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum VariableLengthEnumError {
#[error("value is too large to fit in the target type")]
TooBig,
#[error("encountered error while reading byte stream {source}")]
StreamError {
#[from]
source: std::io::Error,
},
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum FloatWriteError {
#[error("encountered error while writing byte stream {source}")]
StreamError {
#[from]
source: std::io::Error,
},
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum IntegerWriteError {
#[error("encountered error while writing byte stream {source}")]
StreamError {
#[from]
source: std::io::Error,
},
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum StringWriteError {
#[error("encountered error while writing byte stream {source}")]
StreamError {
#[from]
source: std::io::Error,
},
#[error("encountered error while manipulating string length {source}")]
StringLengthError {
#[from]
source: VariableLengthEnumError,
},
}