Skip to main content

Auditor

Trait Auditor 

Source
pub trait Auditor: Send + Sync {
    // Required method
    fn record<'life0, 'async_trait>(
        &'life0 self,
        entry: AuditEntry,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn history<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _item_type: &'life1 str,
        _item_id: &'life2 str,
        _limit: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Value>, StorageError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait { ... }
    fn strict(&self) -> bool { ... }
}
Expand description

A pluggable audit sink. Unlike Authorizer this is async and does I/O — it runs once per mutation, not several times per request.

Required Methods§

Source

fn record<'life0, 'async_trait>( &'life0 self, entry: AuditEntry, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Provided Methods§

Source

fn history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _item_type: &'life1 str, _item_id: &'life2 str, _limit: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Value>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Recorded entries for one record, newest first, capped at limit.

Rows come back in whatever shape the backend stored them; the history page reads the event / whodunnit_email / changes / created_at keys and tolerates their absence. The default returns nothing, so a write-only sink (shipping to syslog, say) needn’t implement reading — the history page then simply shows an empty log.

Source

fn strict(&self) -> bool

Whether a failed audit write should fail the operation that triggered it.

The default is best-effort: the error is logged and the write stands, so a sick audit table cannot take the panel down. Returning true surfaces the failure to the caller as a 500 instead — see emit for exactly what that does and does not guarantee.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Auditor for StorageAuditor

Source§

fn history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, item_type: &'life1 str, item_id: &'life2 str, limit: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Value>, StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, StorageAuditor: 'async_trait,

Newest first, which for an append-only table is descending primary key — stable even when two entries share a created_at timestamp.

Source§

fn record<'life0, 'async_trait>( &'life0 self, entry: AuditEntry, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where 'life0: 'async_trait, StorageAuditor: 'async_trait,

Source§

fn strict(&self) -> bool

Implementors§