use crate::digest::DigestError;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Invalid(&'static str),
#[error("invalid digest")]
Digest(#[from] DigestError),
#[error("invalid boot configuration encoding")]
BootEncoding(#[from] base64::DecodeError),
#[error("invalid protocol JSON")]
Json(#[from] serde_json::Error),
#[error("guest rejected the forwarding handshake")]
Rejected,
#[error("invalid frame length")]
FrameLength,
#[error("frame exceeds protocol limit")]
FrameSize,
#[error("input exceeds {max} bytes")]
InputSize { max: u64 },
#[error("oversized TCP data frame")]
DataFrameSize,
#[error("invalid TCP completion receipt")]
Receipt,
}
impl Error {
pub fn is_invalid_input(&self) -> bool {
!matches!(self, Self::Rejected)
}
}
pub type Result<T, E = Error> = std::result::Result<T, E>;