pub trait SqlAccess:
Send
+ Sync
+ 'static {
// Required methods
fn reader<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn SqlReader>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn writer<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn SqlWriter>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn atomic_unit<'life0, 'async_trait>(
&'life0 self,
op: AtomicUnitOp,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn Any + Send>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn database_path(&self) -> Option<PathBuf> { ... }
}Expand description
Base SQL access capability.
Required Methods§
Sourcefn reader<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn SqlReader>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reader<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn SqlReader>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Acquire a read-only connection from the pool.
Sourcefn writer<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn SqlWriter>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn writer<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn SqlWriter>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Acquire a read-write connection from the pool.
Sourcefn atomic_unit<'life0, 'async_trait>(
&'life0 self,
op: AtomicUnitOp,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn Any + Send>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn atomic_unit<'life0, 'async_trait>(
&'life0 self,
op: AtomicUnitOp,
) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn Any + Send>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run op as ONE atomic unit of work (ADR-067 Component A, Fork C
slice 2).
Where a single-writer task is active (file-backed pool,
KHIVE_WRITE_QUEUE=1), op runs inside that task’s one write
transaction for this request — no separate connection is opened, so
this call cannot compete with the writer task for SQLite’s write
lock. Where no writer task applies (flag off, no runtime, or an
in-memory pool), op runs under a manual
BEGIN IMMEDIATE/COMMIT/ROLLBACK on a writer handle exactly like
calling Self::writer and driving the statements by hand — the
pre-ADR-067 behavior, preserved byte-for-byte on this path.
The atomic-unit suspend-free invariant (normative for every
caller): op’s future must complete on its first poll — it may
issue only synchronous DML against the &mut dyn SqlWriter it is
handed and must never reach a real suspension point (no embedding
computation, no ANN warming, no service or channel await, no
network round-trip). Synchronous external work is forbidden too: no
filesystem/process/network I/O, sleeps, blocking waits, or unbounded CPU
may run between the transaction owner’s BEGIN IMMEDIATE and
COMMIT. First-poll enforcement alone cannot detect those operations;
ADR-091’s write-transaction audit table is the review-time guard, and a
new owner or caller must update that table before merge. On the
single-writer path this is enforced at runtime: the writer task drives
op through a single-poll driver and
returns a typed error the instant the future is Pending, so a
violation fails loudly rather than corrupting state. On the flag-off
path (no writer task active) a suspending op would currently
succeed — that path drives op as an ordinary .await under a
manual transaction — so the invariant is a correctness contract this
trait asks every caller to uphold, not something the type system or
every code path enforces. Callers must not rely on the flag-off
path’s tolerance; behavior must be identical (synchronous DML only)
regardless of whether the single-writer flag is on.
Provided Methods§
Sourcefn database_path(&self) -> Option<PathBuf>
fn database_path(&self) -> Option<PathBuf>
Canonical filesystem identity for this SQL database, when file-backed.
Cross-resource operations use this only to derive advisory coordination
files outside SQLite. Only genuinely pathless, process-private
implementations may return None; every file-backed implementation
must expose its canonical path so cross-process exclusion cannot
silently degrade. The method performs no I/O.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".