#![allow(missing_debug_implementations, missing_docs)]
use crate::Report;
use core::fmt::{Debug, Display};
use crate::StdError;
pub struct Adhoc;
pub trait AdhocKind: Sized {
#[inline]
fn eyre_kind(&self) -> Adhoc {
Adhoc
}
}
impl<T> AdhocKind for &T where T: ?Sized + Display + Debug + Send + Sync + 'static {}
impl Adhoc {
#[cfg_attr(track_caller, track_caller)]
pub fn new<M>(self, message: M) -> Report
where
M: Display + Debug + Send + Sync + 'static,
{
Report::from_adhoc(message)
}
}
pub struct Trait;
pub trait TraitKind: Sized {
#[inline]
fn eyre_kind(&self) -> Trait {
Trait
}
}
impl<E> TraitKind for E where E: Into<Report> {}
impl Trait {
#[cfg_attr(track_caller, track_caller)]
pub fn new<E>(self, error: E) -> Report
where
E: Into<Report>,
{
error.into()
}
}
pub struct Boxed;
pub trait BoxedKind: Sized {
#[inline]
fn eyre_kind(&self) -> Boxed {
Boxed
}
}
impl BoxedKind for Box<dyn StdError + Send + Sync> {}
impl Boxed {
#[cfg_attr(track_caller, track_caller)]
pub fn new(self, error: Box<dyn StdError + Send + Sync>) -> Report {
Report::from_boxed(error)
}
}