Skip to main content

SqlWriter

Trait SqlWriter 

Source
pub trait SqlWriter:
    SqlReader
    + Send
    + 'static {
    // Required methods
    fn execute<'life0, 'async_trait>(
        &'life0 mut self,
        statement: SqlStatement,
    ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn execute_batch<'life0, 'async_trait>(
        &'life0 mut self,
        statements: Vec<SqlStatement>,
    ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn execute_script<'life0, 'async_trait>(
        &'life0 mut self,
        script: String,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn execute_script_top_level<'life0, 'async_trait>(
        &'life0 mut self,
        script: String,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Write-capable SQL connection (extends SqlReader).

Required Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 mut self, statement: SqlStatement, ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute a single DML statement and return the number of rows affected.

Transaction-control rejection is an execute_batch contract; this primitive remains available to internal transaction owners such as atomic_unit for their BEGIN/COMMIT/ROLLBACK calls.

Source

fn execute_batch<'life0, 'async_trait>( &'life0 mut self, statements: Vec<SqlStatement>, ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute multiple DML statements and return the total rows affected.

Source

fn execute_script<'life0, 'async_trait>( &'life0 mut self, script: String, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute a raw SQL script (no parameters; used for migrations).

This script boundary is internal/migration-only and deliberately does not inherit execute_batch’s transaction-control rejection.

Provided Methods§

Source

fn execute_script_top_level<'life0, 'async_trait>( &'life0 mut self, script: String, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute a raw SQL script that MUST run outside any open transaction (ADR-067 Component A, Fork C slice 2) — e.g. VACUUM, which SQLite rejects if issued inside BEGIN/COMMIT.

Default implementation delegates to Self::execute_script: every writer implementation in this codebase except khive-db’s write-queue-routed SqliteWriter already runs execute_script transaction-free (a plain connection call, or already inside a caller-managed transaction where a top-level statement would be invalid regardless of which method is called). SqliteWriter overrides this to route around its writer task’s per-request BEGIN IMMEDIATE specifically for this call, while still serializing through the single writer owner.

This is an internal maintenance boundary (for example VACUUM or a checkpoint script), not an execute_batch transaction-control guard.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§