pub struct AuditEntry { /* private fields */ }Expand description
An audit event to be recorded.
Constructed with four required fields (actor, action, resource_type, resource_id) and optional builder methods for metadata, client context, and tenant.
use modo::audit::AuditEntry;
let entry = AuditEntry::new("user_123", "user.role.changed", "user", "usr_abc")
.metadata(serde_json::json!({"old_role": "editor"}))
.tenant_id("tenant_1");Implementations§
Source§impl AuditEntry
impl AuditEntry
Sourcepub fn new(
actor: impl Into<String>,
action: impl Into<String>,
resource_type: impl Into<String>,
resource_id: impl Into<String>,
) -> Self
pub fn new( actor: impl Into<String>, action: impl Into<String>, resource_type: impl Into<String>, resource_id: impl Into<String>, ) -> Self
Create a new audit entry with four required fields.
Sourcepub fn metadata(self, meta: Value) -> Self
pub fn metadata(self, meta: Value) -> Self
Attach metadata to the audit entry.
Accepts a serde_json::Value — use serde_json::json! at the
call site for structured data, or serde_json::to_value for custom
types.
Sourcepub fn client_info(self, info: ClientInfo) -> Self
pub fn client_info(self, info: ClientInfo) -> Self
Attach client context (IP, user-agent, fingerprint).
Sourcepub fn resource_type(&self) -> &str
pub fn resource_type(&self) -> &str
Returns the resource type (e.g. "user", "document").
Sourcepub fn resource_id(&self) -> &str
pub fn resource_id(&self) -> &str
Returns the resource identifier.
Sourcepub fn metadata_value(&self) -> Option<&Value>
pub fn metadata_value(&self) -> Option<&Value>
Returns the optional metadata JSON value.
Sourcepub fn client_info_value(&self) -> Option<&ClientInfo>
pub fn client_info_value(&self) -> Option<&ClientInfo>
Returns the optional client context.
Sourcepub fn tenant_id_value(&self) -> Option<&str>
pub fn tenant_id_value(&self) -> Option<&str>
Returns the optional tenant ID.
Trait Implementations§
Source§impl Clone for AuditEntry
impl Clone for AuditEntry
Source§fn clone(&self) -> AuditEntry
fn clone(&self) -> AuditEntry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AuditEntry
impl RefUnwindSafe for AuditEntry
impl Send for AuditEntry
impl Sync for AuditEntry
impl Unpin for AuditEntry
impl UnsafeUnpin for AuditEntry
impl UnwindSafe for AuditEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more