orion_error/core/
domain.rs

1use std::fmt::Display;
2
3use super::error::StructError;
4
5pub trait DomainReason: PartialEq + Display {}
6
7#[derive(Debug, PartialEq)]
8pub struct NullReason {}
9impl DomainReason for NullReason {}
10
11pub trait DomainFrom<E, R>
12where
13    R: DomainReason,
14{
15    fn from_domain(reason: E) -> StructError<R>;
16    fn err_from_domain<T>(reason: E) -> Result<T, StructError<R>> {
17        Err(Self::from_domain(reason))
18    }
19}
20
21impl Display for NullReason {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        write!(f, "{}", "NullReason")
24    }
25}