use core::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum RustGenError {
Unsupported {
what: &'static str,
at: usize,
},
InvalidAnnotation {
name: String,
reason: &'static str,
},
UnresolvedType {
scoped: String,
},
}
impl fmt::Display for RustGenError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Unsupported { what, at } => {
write!(
f,
"rust-codegen: unsupported IDL construct `{what}` at offset {at}"
)
}
Self::InvalidAnnotation { name, reason } => {
write!(f, "rust-codegen: invalid annotation `{name}`: {reason}")
}
Self::UnresolvedType { scoped } => {
write!(f, "rust-codegen: unresolved type `{scoped}`")
}
}
}
}
impl std::error::Error for RustGenError {}
pub type Result<T> = core::result::Result<T, RustGenError>;