use thiserror::Error;
#[derive(Debug, Error)]
pub enum MeshError {
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("invalid key format: {0}")]
InvalidKey(String),
#[error("signature verification failed")]
BadSignature,
#[error("invalid cert chain: {0}")]
InvalidCertChain(String),
#[error(
"caveat amplification: a delegated agent may not grant more authority than its parent"
)]
CaveatAmplification,
#[error("expired: {0}")]
Expired(String),
#[error("malformed envelope: {0}")]
MalformedEnvelope(String),
#[error("replay detected: nonce already seen")]
Replay,
#[error("sequence error: expected {expected}, got {actual}")]
BadSequence { expected: u64, actual: u64 },
#[error("encoding error: {0}")]
Encoding(String),
}
pub type Result<T> = std::result::Result<T, MeshError>;