use core::fmt;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct Info {
pub ecause: u16,
pub tval: Option<u64>,
}
impl Info {
pub fn is_interrupt(&self) -> bool {
self.tval.is_none()
}
pub fn is_exception(&self) -> bool {
self.tval.is_some()
}
}
impl fmt::Display for Info {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let ecause = self.ecause;
match self.tval {
Some(tval) => write!(f, "exception (ecause: {ecause}, tval: {tval:0x})"),
None => write!(f, "interrupt (ecause: {ecause})"),
}
}
}