use std::{
error::Error,
fmt::{
self,
Display,
Formatter,
},
};
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DiagnosticBudgetError {
ZeroInput,
OutputTooSmall {
minimum: usize,
actual: usize,
},
}
impl Display for DiagnosticBudgetError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::ZeroInput => formatter
.write_str("diagnostic input budget must be greater than zero"),
Self::OutputTooSmall { minimum, actual } => write!(
formatter,
"diagnostic output budget must be at least {minimum} bytes, got {actual}",
),
}
}
}
impl Error for DiagnosticBudgetError {}