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,
maintenance: TopLevelMaintenance,
) -> 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§
Sourcefn 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<'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.
Sourcefn 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_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.
Sourcefn 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,
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§
Sourcefn execute_script_top_level<'life0, 'async_trait>(
&'life0 mut self,
maintenance: TopLevelMaintenance,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute_script_top_level<'life0, 'async_trait>(
&'life0 mut self,
maintenance: TopLevelMaintenance,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute one closed-set maintenance operation that MUST run outside any
open transaction (ADR-067 Component A, Fork C slice 2). VACUUM, for
example, is rejected by SQLite 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.
SQL is rendered only from TopLevelMaintenance’s static literals;
this API does not accept caller-supplied or formatted SQL. It is an
internal maintenance boundary, not an execute_batch transaction-control
guard. The separate migration-only Self::execute_script is unchanged.
use khive_storage::{SqlWriter, StorageResult, TopLevelMaintenance};
async fn maintain(writer: &mut dyn SqlWriter) -> StorageResult<()> {
writer.execute_script_top_level(TopLevelMaintenance::Vacuum).await?;
writer.execute_script_top_level(TopLevelMaintenance::WalCheckpointTruncate).await
}A runtime string cannot cross this boundary, even if its current contents happen to be a supported maintenance statement:
use khive_storage::{SqlWriter, StorageResult};
async fn reject_script(writer: &mut dyn SqlWriter, script: String) -> StorageResult<()> {
writer.execute_script_top_level(script).await
}Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".