Skip to main content

Prepared

Struct Prepared 

Source
pub struct Prepared<D, Params, Output> { /* private fields */ }
Expand description

A query rendered once, with its Value::Placeholder(name) slots left unresolved, reusable across many .load(executor, params) calls. load takes the exact Params struct prepare!{} generated for this query, so a missing or mistyped value is caught. The dialect it was rendered in stays in its type, so it can only be run by an executor of that dialect — the same rule Select and DynSelect follow.

Params is a free parameter, though — nothing ties the placeholder names baked into the template to the struct that fills them — so a query built from one prepare! struct and run with another is caught at resolve rather than at compile time. Placeholder names are qualified by the module and struct they were declared in, so that mismatch is always an UnresolvedPlaceholder and never a value bound to the wrong slot.

Implementations§

Source§

impl<D, Params: PreparedParams, Output> Prepared<D, Params, Output>

Source

pub fn resolve( &self, params: Params, ) -> Result<(String, Vec<Value>), UnresolvedPlaceholder>

Substitutes every named placeholder with the matching value from params, producing the same (String, Vec<Value>) shape to_sql() returns.

Auto Trait Implementations§

§

impl<D, Params, Output> Freeze for Prepared<D, Params, Output>

§

impl<D, Params, Output> RefUnwindSafe for Prepared<D, Params, Output>

§

impl<D, Params, Output> Send for Prepared<D, Params, Output>

§

impl<D, Params, Output> Sync for Prepared<D, Params, Output>

§

impl<D, Params, Output> Unpin for Prepared<D, Params, Output>

§

impl<D, Params, Output> UnsafeUnpin for Prepared<D, Params, Output>

§

impl<D, Params, Output> UnwindSafe for Prepared<D, Params, Output>

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<S> Superset<Nil, Nil> for S

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WrapNullable<NotNull> for T