Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
    // Required methods
    fn insert<'life0, 'async_trait>(
        &'life0 self,
        audit: NewAudit,
    ) -> Pin<Box<dyn Future<Output = Result<Audit>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn audits_for_auditable<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        auditable_type: &'life1 str,
        auditable_id: &'life2 AuditId,
        query: &'life3 AuditQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Audit>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn audits_for_associated<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        associated_type: &'life1 str,
        associated_id: &'life2 AuditId,
        query: &'life3 AuditQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Audit>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn own_and_associated_audits<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        auditable_type: &'life1 str,
        auditable_id: &'life2 AuditId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Audit>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn count_for_auditable<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        auditable_type: &'life1 str,
        auditable_id: &'life2 AuditId,
    ) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn find<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Audit>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn combine<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        target_id: i64,
        merged_changes: &'life1 AuditedChanges,
        comment: Option<&'life2 str>,
        older_ids: &'life3 [i64],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Where to store and how to retrieve audits.

Implementations must:

  • assign version at insert time — 1 for crate::Action::Create, otherwise max(version) + 1 for the (auditable_type, auditable_id) — ideally inside a transaction guarded by a unique constraint on (auditable_type, auditable_id, version).
  • apply AuditQuery filters and ordering exactly.

Required Methods§

Source

fn insert<'life0, 'async_trait>( &'life0 self, audit: NewAudit, ) -> Pin<Box<dyn Future<Output = Result<Audit>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert a new audit, assigning its version, and return the persisted row.

Source

fn audits_for_auditable<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, auditable_type: &'life1 str, auditable_id: &'life2 AuditId, query: &'life3 AuditQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<Audit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

All audits for one auditable record, filtered/ordered by query.

Source

fn audits_for_associated<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, associated_type: &'life1 str, associated_id: &'life2 AuditId, query: &'life3 AuditQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<Audit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

All audits whose associated points at the given record (the record’s associated audits).

Source

fn own_and_associated_audits<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, auditable_type: &'life1 str, auditable_id: &'life2 AuditId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Audit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Union of a record’s own audits and its associated audits, ordered by created_at descending, newest first.

Source

fn count_for_auditable<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, auditable_type: &'life1 str, auditable_id: &'life2 AuditId, ) -> Pin<Box<dyn Future<Output = Result<i64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Count of audits for one auditable record.

Source

fn find<'life0, 'async_trait>( &'life0 self, id: i64, ) -> Pin<Box<dyn Future<Output = Result<Option<Audit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch a single audit by primary key.

Source

fn combine<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, target_id: i64, merged_changes: &'life1 AuditedChanges, comment: Option<&'life2 str>, older_ids: &'life3 [i64], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Combine pruned audits: overwrite target’s changes/comment and delete the older_ids, atomically. Used by max_audits pruning. Deadlock-class errors should be treated as success (a concurrent identical combine already won).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§