MiddlewarePoolConnection

Enum MiddlewarePoolConnection 

Source
pub enum MiddlewarePoolConnection {
    Postgres {
        client: Object,
        translate_placeholders: bool,
    },
    Sqlite {
        conn: SqliteConnection,
        translate_placeholders: bool,
    },
}

Variants§

§

Postgres

Fields

§client: Object
§translate_placeholders: bool
§

Sqlite

Fields

§translate_placeholders: bool

Implementations§

Source§

impl MiddlewarePoolConnection

Source

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

Executes a batch of SQL queries within a transaction by delegating to the specific database module.

§Errors

Returns an error if the selected backend cannot execute the batch or the database responds with an error.

Source

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

Start a fluent query builder that can translate placeholders before executing.

Source§

impl MiddlewarePoolConnection

Source

pub async fn with_sqlite_connection<F, R>( &mut self, func: F, ) -> Result<R, SqlMiddlewareDbError>
where F: FnOnce(&mut Connection) -> Result<R, SqlMiddlewareDbError> + Send + 'static, R: Send + 'static,

Run synchronous SQLite work on the underlying worker-owned connection.

§Errors

Returns SqlMiddlewareDbError::Unimplemented when the connection is not SQLite.

Source

pub async fn prepare_sqlite_statement( &mut self, query: &str, ) -> Result<SqlitePreparedStatement, SqlMiddlewareDbError>

Prepare a SQLite statement and obtain a reusable handle backed by the worker thread.

§Errors

Returns SqlMiddlewareDbError::Unimplemented when the underlying connection is not SQLite, or propagates any preparation error reported by the worker thread.

Source

pub fn translation_default(&self) -> bool

Pool-default translation toggle attached to this connection.

Source§

impl MiddlewarePoolConnection

Source

pub async fn interact_async<F, Fut>( &mut self, func: F, ) -> Result<Fut::Output, SqlMiddlewareDbError>
where F: FnOnce(AnyConnWrapper<'_>) -> Fut + Send + 'static, Fut: Future<Output = Result<(), SqlMiddlewareDbError>> + Send + 'static,

Interact with the connection asynchronously

§Errors

Returns SqlMiddlewareDbError::Unimplemented for unsupported database types.

Source

pub async fn interact_sync<F, R>(&self, f: F) -> Result<R, SqlMiddlewareDbError>
where F: FnOnce(AnyConnWrapper<'_>) -> R + Send + 'static, R: Send + 'static,

Interact with the connection synchronously

§Errors

Returns SqlMiddlewareDbError::Unimplemented for unsupported database types.

Trait Implementations§

Source§

impl Debug for MiddlewarePoolConnection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more