pub trait AnyWriteRequest: Sealed + Send {
// Required methods
fn execute_and_reply(self: Box<Self>, conn: &Connection);
fn execute_and_reply_top_level(self: Box<Self>, conn: &Connection);
fn reply_error(self: Box<Self>, err: StorageError);
fn is_top_level(&self) -> bool;
}Expand description
Type-erased write request the writer task’s drain loop can hold in a
homogeneous channel (mpsc::Sender<Box<dyn AnyWriteRequest + Send>>),
while each concrete WriteRequest<R> still carries its own typed
reply. Sealed: only this module may implement it (ADR-067 lines
210-212).
Required Methods§
Sourcefn execute_and_reply(self: Box<Self>, conn: &Connection)
fn execute_and_reply(self: Box<Self>, conn: &Connection)
Runs this request’s operation against conn, commits or rolls back
the enclosing transaction based on the outcome, and sends the
(possibly commit-failure-adjusted) result to the request’s oneshot
reply channel.
conn must already be inside a successfully-opened BEGIN IMMEDIATE
transaction opened by the caller (run_writer_task) — this method
issues only COMMIT / ROLLBACK, never BEGIN, so run_writer_task
remains the sole issuer of BEGIN IMMEDIATE (ADR-067 Component A).
Callers must use Self::reply_error instead when the enclosing
BEGIN IMMEDIATE itself failed — this method must not be invoked in
that case.
Sourcefn execute_and_reply_top_level(self: Box<Self>, conn: &Connection)
fn execute_and_reply_top_level(self: Box<Self>, conn: &Connection)
Runs this request’s operation directly against conn — no
transaction wrap, no COMMIT/ROLLBACK — and sends the result to
the request’s oneshot reply channel.
Used only for Self::is_top_level requests: the drain loop calls
this INSTEAD of execute_and_reply for such requests, skipping
BEGIN IMMEDIATE entirely so a statement that must run outside any
transaction (e.g. VACUUM) can still be serialized through the
single writer owner.
Sourcefn reply_error(self: Box<Self>, err: StorageError)
fn reply_error(self: Box<Self>, err: StorageError)
Replies with err without running this request’s operation or
touching conn.
Used when the enclosing BEGIN IMMEDIATE failed (for example,
SQLITE_BUSY from lock contention with an unmigrated writer path
still holding the pool’s writer mutex — reachable while only
entity.rs is routed through this channel). Running the operation
anyway would execute its DML against conn in autocommit mode,
landing partial writes for a request the caller is told failed.
Skipping the operation entirely keeps “the caller got an error” and
“no rows landed” true together.
Sourcefn is_top_level(&self) -> bool
fn is_top_level(&self) -> bool
true if the drain loop must run this request via
Self::execute_and_reply_top_level (no transaction wrap) instead
of Self::execute_and_reply (wrapped in BEGIN IMMEDIATE).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".