use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Protocol(#[from] crate::protocol::Error),
#[cfg(feature = "std")]
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("transport error: {0}")]
Transport(#[from] crate::transport::TransportError),
#[error(transparent)]
E2e(#[from] crate::e2e::Error),
#[error("internal capacity exceeded: {0}")]
Capacity(&'static str),
#[error("invalid server usage: {0}")]
InvalidUsage(&'static str),
}
impl From<crate::protocol::sd::Error> for Error {
fn from(err: crate::protocol::sd::Error) -> Self {
Self::Protocol(crate::protocol::Error::from(err))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn from_sd_error_produces_protocol_variant() {
let sd_err = crate::protocol::sd::Error::IncorrectEntriesSize(0);
let err: Error = sd_err.into();
assert!(matches!(err, Error::Protocol(_)));
}
}