pub struct SqlContext<'ctx, 'conn> { /* private fields */ }Expand description
Host SQL inside one journaled write transaction.
The context exposes SQL operations, but never the underlying SQLite connection or transaction. In particular, a host cannot remove coven’s SQL authorizer and address its attached gate baseline:
ⓘ
handle.sql(|sql| {
sql.tx().authorizer(
None::<fn(coven::rusqlite::hooks::AuthContext<'_>)
-> coven::rusqlite::hooks::Authorization>,
)?;
Ok(())
}).await?;Implementations§
Source§impl<'ctx, 'conn> SqlContext<'ctx, 'conn>
impl<'ctx, 'conn> SqlContext<'ctx, 'conn>
Sourcepub fn execute<P>(&self, sql: &str, params: P) -> Result<usize>where
P: Params,
pub fn execute<P>(&self, sql: &str, params: P) -> Result<usize>where
P: Params,
Execute one SQL statement with bound parameters.
Sourcepub fn execute_batch(&self, sql: &str) -> Result<()>
pub fn execute_batch(&self, sql: &str) -> Result<()>
Execute one or more semicolon-separated SQL statements.
Sourcepub fn query_row<T, P, F>(&self, sql: &str, params: P, map: F) -> Result<T>where
P: Params,
F: FnOnce(&Row<'_>) -> Result<T>,
pub fn query_row<T, P, F>(&self, sql: &str, params: P, map: F) -> Result<T>where
P: Params,
F: FnOnce(&Row<'_>) -> Result<T>,
Query exactly one row and map it to a host value.
Sourcepub fn query<T, P, F>(&self, sql: &str, params: P, map: F) -> Result<Vec<T>>where
P: Params,
F: FnMut(&Row<'_>) -> Result<T>,
pub fn query<T, P, F>(&self, sql: &str, params: P, map: F) -> Result<Vec<T>>where
P: Params,
F: FnMut(&Row<'_>) -> Result<T>,
Query any number of rows and collect their mapped host values.
pub fn stamp(&self) -> String
Auto Trait Implementations§
impl<'ctx, 'conn> Freeze for SqlContext<'ctx, 'conn>
impl<'ctx, 'conn> !RefUnwindSafe for SqlContext<'ctx, 'conn>
impl<'ctx, 'conn> !Send for SqlContext<'ctx, 'conn>
impl<'ctx, 'conn> !Sync for SqlContext<'ctx, 'conn>
impl<'ctx, 'conn> Unpin for SqlContext<'ctx, 'conn>
impl<'ctx, 'conn> UnsafeUnpin for SqlContext<'ctx, 'conn>
impl<'ctx, 'conn> !UnwindSafe for SqlContext<'ctx, 'conn>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.