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