Files
k-mood/crates/domain/src/events/event_envelope.rs
Gabriel Kaszewski 95739892de
Some checks failed
CI / ci (push) Failing after 1m48s
init
2026-08-25 23:24:36 +02:00

35 lines
620 B
Rust

use chrono::{DateTime, Utc};
use super::{DomainEvent, EventId};
#[derive(Debug, Clone)]
pub struct EventEnvelope {
id: EventId,
event: DomainEvent,
occurred_at: DateTime<Utc>,
}
impl EventEnvelope {
pub fn wrap(event: DomainEvent) -> Self {
Self {
id: EventId::generate(),
event,
occurred_at: Utc::now(),
}
}
}
impl EventEnvelope {
pub fn id(&self) -> &EventId {
&self.id
}
pub fn event(&self) -> &DomainEvent {
&self.event
}
pub fn occurred_at(&self) -> &DateTime<Utc> {
&self.occurred_at
}
}