pub struct AuditLog(/* private fields */);Expand description
Concrete audit log service.
Wraps an AuditLogBackend behind Arc for cheap cloning.
Register with .with_service(audit_log) and extract as
Service(audit): Service<AuditLog>.
Two write methods:
record()— propagates errors viaResultrecord_silent()— traces errors, never fails
Implementations§
Source§impl AuditLog
impl AuditLog
Sourcepub fn new(db: Database) -> Self
pub fn new(db: Database) -> Self
Create with the built-in SQLite backend writing to the audit_log table.
Sourcepub fn from_backend(backend: Arc<dyn AuditLogBackend>) -> Self
pub fn from_backend(backend: Arc<dyn AuditLogBackend>) -> Self
Create with a custom backend.
Sourcepub async fn record(&self, entry: &AuditEntry) -> Result<()>
pub async fn record(&self, entry: &AuditEntry) -> Result<()>
Record an audit event, propagating errors via Result.
§Errors
Returns an error if the backend write fails (e.g. database connection lost, constraint violation).
Sourcepub async fn record_silent(&self, entry: &AuditEntry)
pub async fn record_silent(&self, entry: &AuditEntry)
Record an audit event. Traces errors, never fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuditLog
impl !RefUnwindSafe for AuditLog
impl Send for AuditLog
impl Sync for AuditLog
impl Unpin for AuditLog
impl UnsafeUnpin for AuditLog
impl !UnwindSafe for AuditLog
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