use super::*;
use static_assertions::assert_obj_safe;
use std::fmt::Debug;
assert_obj_safe!(Diag);
pub trait Diag: Debug + Send + Sync {
fn severity(&self) -> Severity;
fn build(&self, builder: Builder) -> Builder;
}
pub type Result<T> = std::result::Result<T, DiagBox>;
pub struct DiagBox(Box<dyn Diag + Send + Sync>);
impl std::fmt::Debug for DiagBox {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
impl<E> From<E> for DiagBox
where
E: Diag + 'static,
{
fn from(value: E) -> Self {
DiagBox(Box::new(value))
}
}
impl std::ops::Deref for DiagBox {
type Target = Box<dyn Diag + Send + Sync>;
fn deref(&self) -> &Self::Target {
&self.0
}
}