pub struct AuditMetadata {
pub actor_id: String,
pub actor_session_id: Option<String>,
pub source_ip: Option<String>,
pub user_agent: Option<String>,
pub timestamp_utc_us: i64,
pub causation_id: Option<Uuid>,
pub correlation_id: Uuid,
}Expand description
Audit fields stamped on every persisted event.
See module docs for the lifecycle and reserved actor identifiers.
Fields§
§actor_id: StringRequired. Aggregate UUID, "system", "anonymous", or "legacy-pre-hipaa".
Must be non-empty after trim.
actor_session_id: Option<String>Optional. The session this command was dispatched in. Pair with HIPAA-4 server-side session store for revocation.
source_ip: Option<String>Optional. Source IP. None for system-internal commands.
user_agent: Option<String>Optional. User-Agent header.
timestamp_utc_us: i64Required. Microseconds since UNIX epoch. Must be > 0.
causation_id: Option<Uuid>Optional. Event ID that triggered the command that produced this event (saga / projection-driven follow-up).
correlation_id: UuidRequired. Groups every event from one logical request together.
CommandContext::system synthesizes one for internal jobs.
Implementations§
Source§impl AuditMetadata
impl AuditMetadata
Sourcepub fn new(
actor_id: impl Into<String>,
correlation_id: Uuid,
) -> Result<Self, AuditError>
pub fn new( actor_id: impl Into<String>, correlation_id: Uuid, ) -> Result<Self, AuditError>
Construct a new validated AuditMetadata from raw inputs.
timestamp_utc_us is set from the system clock. Use
[AuditMetadata::with_timestamp] to supply an explicit value (testing,
replay, deterministic builds).
Sourcepub fn system() -> Self
pub fn system() -> Self
Convenience constructor for system-internal jobs (cron, seeders, migrations).
Synthesizes a correlation_id. Always passes validation.
Sourcepub fn pending() -> Self
pub fn pending() -> Self
Placeholder value used by Event::new. The CommandBus overwrites this
with a real value from the request CommandContext before append.
Calling validate() on a pending value returns
AuditError::PendingNotStamped — the store rejects the write.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
True when audit == pending(). Stores reject pending audits at append-time.
Sourcepub fn validate(&self) -> Result<(), AuditError>
pub fn validate(&self) -> Result<(), AuditError>
Defense-in-depth validation. Stores call this at the top of append.
Trait Implementations§
Source§impl Clone for AuditMetadata
impl Clone for AuditMetadata
Source§fn clone(&self) -> AuditMetadata
fn clone(&self) -> AuditMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more