Skip to main content

Database

Trait Database 

Source
pub trait Database: Send + Sync {
    // Required methods
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stmt: &'life1 Statement,
    ) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stmt: &'life1 Statement,
    ) -> Pin<Box<dyn Future<Output = Result<Rows, DbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn batch_atomic<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stmts: &'life1 [Statement],
    ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Execute statements against the venture database. Implementations: D1 (Workers), rusqlite (tests, self-hosted), Postgres (phase 3).

batch_atomic is all-or-nothing, on every adapter, without exception (issue #126). Either every statement commits or none does: a failure part-way through leaves the database exactly as it was, as if the batch never ran. This is a port contract, not an adapter nicety — confirmation, position assignment and referral credit each span several statements and are correct only if they commit together — so an adapter that cannot honour it must not implement this trait, and the testing kit’s assert_batch_is_atomic enforces the contract per engine in CI. Per-statement row counts are not reported; a caller that needs to know whether a statement changed anything reads the row back (see module-waitlist’s confirm_entry).

Required Methods§

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, stmt: &'life1 Statement, ) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn query<'life0, 'life1, 'async_trait>( &'life0 self, stmt: &'life1 Statement, ) -> Pin<Box<dyn Future<Output = Result<Rows, DbError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn batch_atomic<'life0, 'life1, 'async_trait>( &'life0 self, stmts: &'life1 [Statement], ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§