SqliteTypedConnection

Struct SqliteTypedConnection 

Source
pub struct SqliteTypedConnection<State> { /* private fields */ }
Expand description

Typestate wrapper around a pooled SQLite connection.

When in InTx state, dropping without calling commit or rollback will trigger a best-effort synchronous rollback in Drop to keep the pool clean. Prefer finishing transactions explicitly to avoid surprise blocking work during drop.

Implementations§

Source§

impl SqliteTypedConnection<Idle>

Source

pub async fn from_pool( pool: &Pool<SqliteManager>, ) -> Result<Self, SqlMiddlewareDbError>

Checkout a connection from the pool.

§Errors

Returns SqlMiddlewareDbError if acquiring a pooled connection fails.

Source§

impl SqliteTypedConnection<Idle>

Source

pub async fn execute_batch( &mut self, sql: &str, ) -> Result<(), SqlMiddlewareDbError>

Auto-commit batch (BEGIN/COMMIT around it).

§Errors

Returns SqlMiddlewareDbError if executing the batch fails.

Source

pub async fn dml( &mut self, query: &str, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>

Auto-commit DML.

§Errors

Returns SqlMiddlewareDbError if executing the DML fails.

Source§

impl SqliteTypedConnection<InTx>

Source

pub async fn execute_batch( &mut self, sql: &str, ) -> Result<(), SqlMiddlewareDbError>

Execute batch inside the open transaction.

§Errors

Returns SqlMiddlewareDbError if executing the batch fails.

Source

pub async fn dml( &mut self, query: &str, params: &[RowValues], ) -> Result<usize, SqlMiddlewareDbError>

Execute DML inside the open transaction.

§Errors

Returns SqlMiddlewareDbError if executing the DML fails.

Source§

impl SqliteTypedConnection<Idle>

Source

pub async fn select( &mut self, query: &str, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>

Auto-commit SELECT.

§Errors

Returns SqlMiddlewareDbError if executing the select fails.

Source

pub fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>

Start a query builder (auto-commit per operation).

Source§

impl SqliteTypedConnection<InTx>

Source

pub async fn select( &mut self, query: &str, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>

Execute SELECT inside the open transaction.

§Errors

Returns SqlMiddlewareDbError if executing the select fails.

Source

pub fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>

Start a query builder within the open transaction.

Source§

impl SqliteTypedConnection<Idle>

Source

pub async fn begin( self, ) -> Result<SqliteTypedConnection<InTx>, SqlMiddlewareDbError>

Begin an explicit transaction.

§Errors

Returns SqlMiddlewareDbError if transitioning into a transaction fails.

Source§

impl SqliteTypedConnection<InTx>

Source

pub async fn commit( self, ) -> Result<SqliteTypedConnection<Idle>, SqlMiddlewareDbError>

Commit and return to idle.

§Errors

Returns SqlMiddlewareDbError if committing the transaction fails.

Source

pub async fn rollback( self, ) -> Result<SqliteTypedConnection<Idle>, SqlMiddlewareDbError>

Rollback and return to idle.

§Errors

Returns SqlMiddlewareDbError if rolling back the transaction fails.

Trait Implementations§

Source§

impl BeginTx for SqliteTypedConnection<Idle>

Source§

impl<State> Drop for SqliteTypedConnection<State>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Queryable for SqliteTypedConnection<Idle>

Source§

fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>

Source§

impl Queryable for SqliteTypedConnection<InTx>

Source§

fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>

Source§

impl TxConn for SqliteTypedConnection<InTx>

Source§

type Idle = SqliteTypedConnection<Idle>

Source§

fn commit( self, ) -> impl Future<Output = Result<Self::Idle, SqlMiddlewareDbError>>

Source§

fn rollback( self, ) -> impl Future<Output = Result<Self::Idle, SqlMiddlewareDbError>>

Source§

impl TypedConnOps for SqliteTypedConnection<Idle>

Source§

fn execute_batch( &mut self, sql: &str, ) -> impl Future<Output = Result<(), SqlMiddlewareDbError>>

Source§

fn dml( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<usize, SqlMiddlewareDbError>>

Source§

fn select( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<ResultSet, SqlMiddlewareDbError>>

Source§

impl TypedConnOps for SqliteTypedConnection<InTx>

Source§

fn execute_batch( &mut self, sql: &str, ) -> impl Future<Output = Result<(), SqlMiddlewareDbError>>

Source§

fn dml( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<usize, SqlMiddlewareDbError>>

Source§

fn select( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<ResultSet, SqlMiddlewareDbError>>

Auto Trait Implementations§

§

impl<State> Freeze for SqliteTypedConnection<State>

§

impl<State> !RefUnwindSafe for SqliteTypedConnection<State>

§

impl<State> Send for SqliteTypedConnection<State>
where State: Send,

§

impl<State> Sync for SqliteTypedConnection<State>
where State: Sync,

§

impl<State> Unpin for SqliteTypedConnection<State>
where State: Unpin,

§

impl<State> !UnwindSafe for SqliteTypedConnection<State>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V