Skip to main content

QueryTarget

Enum QueryTarget 

Source
pub enum QueryTarget<'a> {
    Pool(&'a Pool),
    Conn(&'a mut PoolConnection),
    Tx(&'a mut Transaction),
}
Expand description

Concrete enum for query dispatch. Replaces the Executor trait.

Generated code converts the user-supplied executor (&Pool, &mut PoolConnection, or &mut Transaction) into QueryTarget via Into, then calls query_raw / query_raw_readonly / execute_raw.

Pool takes a shared reference (&Pool) because it acquires from the pool internally. PoolConnection and Transaction take exclusive references (&mut) — no Mutex needed.

Variants§

§

Pool(&'a Pool)

§

Conn(&'a mut PoolConnection)

§

Tx(&'a mut Transaction)

Implementations§

Source§

impl<'a> QueryTarget<'a>

Source

pub fn query_raw( self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], ) -> BsqlResult<OwnedResult>

Execute a query and return all rows.

Source

pub fn query_raw_readonly( self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], ) -> BsqlResult<OwnedResult>

Execute a read-only query. Routes to replicas for Pool when configured.

Source

pub fn execute_raw( self, sql: &str, sql_hash: u64, params: &[&(dyn Encode + Sync)], ) -> BsqlResult<u64>

Execute a query and return the number of affected rows.

Trait Implementations§

Source§

impl<'a> From<&'a PgPool> for QueryTarget<'a>

Source§

fn from(pool: &'a Pool) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut PoolConnection> for QueryTarget<'a>

Source§

fn from(conn: &'a mut PoolConnection) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut Transaction> for QueryTarget<'a>

Source§

fn from(tx: &'a mut Transaction) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for QueryTarget<'a>

§

impl<'a> RefUnwindSafe for QueryTarget<'a>

§

impl<'a> Send for QueryTarget<'a>

§

impl<'a> Sync for QueryTarget<'a>

§

impl<'a> Unpin for QueryTarget<'a>

§

impl<'a> UnsafeUnpin for QueryTarget<'a>

§

impl<'a> !UnwindSafe for QueryTarget<'a>

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.