Skip to main content

appletheia_application/outbox/
outbox_dead_lettered_at.rs

1use std::{fmt, fmt::Display};
2
3use chrono::{DateTime, Utc};
4
5#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
6pub struct OutboxDeadLetteredAt(DateTime<Utc>);
7
8impl OutboxDeadLetteredAt {
9    pub fn now() -> Self {
10        Self(Utc::now())
11    }
12
13    pub fn value(&self) -> DateTime<Utc> {
14        self.0
15    }
16}
17
18impl Default for OutboxDeadLetteredAt {
19    fn default() -> Self {
20        Self::now()
21    }
22}
23
24impl From<DateTime<Utc>> for OutboxDeadLetteredAt {
25    fn from(value: DateTime<Utc>) -> Self {
26        Self(value)
27    }
28}
29
30impl From<OutboxDeadLetteredAt> for DateTime<Utc> {
31    fn from(value: OutboxDeadLetteredAt) -> Self {
32        value.0
33    }
34}
35
36impl Display for OutboxDeadLetteredAt {
37    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38        write!(f, "{}", self.value())
39    }
40}