pub struct TemplateArg<'q, DB: Database, D> { /* private fields */ }
Expand description
SQL template argument processor handling safe parameter encoding and placeholder generation
§Generic Parameters
'q
: Lifetime for database argumentsDB
: Database type implementing [sqlx::Database
]D
: Template data type
Implementations§
Source§impl<'q, DB: Database, D> TemplateArg<'q, DB, D>
impl<'q, DB: Database, D> TemplateArg<'q, DB, D>
Sourcepub fn new(d: &'q D) -> Self
pub fn new(d: &'q D) -> Self
Creates a new TemplateArg instance wrapping template data
§Arguments
d
- Reference to template data with lifetime'q
Sourcepub fn set_encode_placeholder_fn(&mut self, f: fn(usize, &mut String))
pub fn set_encode_placeholder_fn(&mut self, f: fn(usize, &mut String))
Sets custom placeholder formatting function
§Arguments
f
- Function that takes parameter index and appends placeholder
Sourcepub fn el<ImplEncode>(
&self,
args: impl IntoIterator<Item = ImplEncode>,
) -> String
pub fn el<ImplEncode>( &self, args: impl IntoIterator<Item = ImplEncode>, ) -> String
Sourcepub fn et<ImplEncode>(&self, t: &ImplEncode) -> String
pub fn et<ImplEncode>(&self, t: &ImplEncode) -> String
Clone-and-encode variant for types requiring cloning
§Arguments
t
- Reference to clonable encodable value
Sourcepub fn etl<'arg_b, ImplEncode>(
&self,
args: impl IntoIterator<Item = &'arg_b ImplEncode>,
) -> String
pub fn etl<'arg_b, ImplEncode>( &self, args: impl IntoIterator<Item = &'arg_b ImplEncode>, ) -> String
Sourcepub fn get_arguments(&self) -> Option<DB::Arguments<'q>>
pub fn get_arguments(&self) -> Option<DB::Arguments<'q>>
Takes ownership of the encoded arguments
Trait Implementations§
Auto Trait Implementations§
impl<'q, DB, D> !Freeze for TemplateArg<'q, DB, D>
impl<'q, DB, D> !RefUnwindSafe for TemplateArg<'q, DB, D>
impl<'q, DB, D> Send for TemplateArg<'q, DB, D>where
D: Sync,
impl<'q, DB, D> !Sync for TemplateArg<'q, DB, D>
impl<'q, DB, D> Unpin for TemplateArg<'q, DB, D>
impl<'q, DB, D> !UnwindSafe for TemplateArg<'q, DB, D>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 more