use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error(
"sample is too large for the configured frame size: need at least {needed} bytes of payload, have {available}"
)]
SampleTooLarge {
needed: usize,
available: usize,
},
#[error("could not decode a peaveil sample: {0}")]
Decode(String),
#[error("invalid configuration: {0}")]
Config(String),
}
impl From<peashape::Error> for Error {
fn from(e: peashape::Error) -> Self {
match e {
peashape::Error::Io(io) => Error::Io(io),
other => Error::Io(std::io::Error::other(other.to_string())),
}
}
}