use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum WireError {
#[error("xenia wire codec: {0}")]
Codec(String),
#[error("xenia wire: session key not established")]
NoSessionKey,
#[error("xenia wire: AEAD seal failed")]
SealFailed,
#[error("xenia wire: AEAD open failed")]
OpenFailed,
#[error("xenia wire: sequence space exhausted — rekey required")]
SequenceExhausted,
#[cfg(feature = "consent")]
#[error("xenia wire: consent ceremony not completed — FRAME refused")]
NoConsent,
#[cfg(feature = "consent")]
#[error("xenia wire: consent revoked — session terminated")]
ConsentRevoked,
#[cfg(feature = "consent")]
#[error("xenia wire: consent protocol violation: {0}")]
ConsentProtocolViolation(crate::consent::ConsentViolation),
}
impl WireError {
pub fn encode<E: core::fmt::Display>(e: E) -> Self {
Self::Codec(format!("encode: {e}"))
}
pub fn decode<E: core::fmt::Display>(e: E) -> Self {
Self::Codec(format!("decode: {e}"))
}
}