#[non_exhaustive]pub struct AuditRecord {
pub id: AuditRecordId,
pub schema_version: u16,
pub actor_json: Value,
pub operation: String,
pub target_ref: String,
pub created_at: DateTime<Utc>,
pub outcome: Outcome,
pub correlation_id: Option<CorrelationId>,
}Expand description
Doctrine-compliant audit record.
Required fields are positional in AuditRecord::new. There is no
Default and no public field-init shorthand outside this module’s tests.
See module docs for the full doctrine and anti-criterion.
Field order matches the audit_records columns in BUILD_SPEC §10 where
they overlap; doctrine-only fields (outcome, correlation_id) are added
at the end so the wire shape is forward-compatible with the §10 table.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: AuditRecordIdStable identifier.
schema_version: u16Schema version this row was written under.
actor_json: ValueFree-form actor descriptor (e.g. {"kind": "operator", "username": "alice"}). Opaque at this layer; see module-level anti-criterion.
operation: StringStable operation identifier (e.g. principle.promote,
memory.accept).
target_ref: StringFree-form reference to the target of the operation (typically a prefix-ULID ID, but any stable string is allowed).
created_at: DateTime<Utc>When the audit row was created, in UTC.
outcome: OutcomeOutcome of the operation.
correlation_id: Option<CorrelationId>Optional cross-trace correlation identifier.
Implementations§
Source§impl AuditRecord
impl AuditRecord
Sourcepub fn new(
actor_json: Value,
operation: String,
target_ref: String,
created_at: DateTime<Utc>,
outcome: Outcome,
) -> Self
pub fn new( actor_json: Value, operation: String, target_ref: String, created_at: DateTime<Utc>, outcome: Outcome, ) -> Self
Construct a new audit record.
All doctrine-required fields are positional and required. This is
the only public constructor: there is no Default::default() and no
builder. Forgetting any required field is a compile error, not a
runtime validation failure.
id is generated fresh; schema_version is set to
crate::SCHEMA_VERSION.
Sourcepub fn with_correlation(self, correlation_id: CorrelationId) -> Self
pub fn with_correlation(self, correlation_id: CorrelationId) -> Self
Attach an optional correlation id (chainable).
Trait Implementations§
Source§impl Clone for AuditRecord
impl Clone for AuditRecord
Source§fn clone(&self) -> AuditRecord
fn clone(&self) -> AuditRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuditRecord
impl Debug for AuditRecord
Source§impl<'de> Deserialize<'de> for AuditRecord
impl<'de> Deserialize<'de> for AuditRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for AuditRecord
impl JsonSchema for AuditRecord
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl PartialEq for AuditRecord
impl PartialEq for AuditRecord
Source§fn eq(&self, other: &AuditRecord) -> bool
fn eq(&self, other: &AuditRecord) -> bool
self and other values to be equal, and is used by ==.