pub struct Context<'a> { /* private fields */ }
functions
only.Expand description
Context is a wrapper for the SQLite function evaluation context.
Implementations§
source§impl Context<'_>
impl Context<'_>
sourcepub fn get<T: FromSql>(&self, idx: usize) -> Result<T>
pub fn get<T: FromSql>(&self, idx: usize) -> Result<T>
Returns the idx
th argument as a T
.
Failure
Will panic if idx
is greater than or equal to
self.len()
.
Will return Err if the underlying SQLite type cannot be converted to a
T
.
sourcepub fn get_raw(&self, idx: usize) -> ValueRef<'_>
pub fn get_raw(&self, idx: usize) -> ValueRef<'_>
Returns the idx
th argument as a ValueRef
.
Failure
Will panic if idx
is greater than or equal to
self.len()
.
sourcepub fn get_subtype(&self, idx: usize) -> c_uint
pub fn get_subtype(&self, idx: usize) -> c_uint
Returns the subtype of idx
th argument.
Failure
Will panic if idx
is greater than or equal to
self.len()
.
sourcepub fn get_or_create_aux<T, E, F>(&self, arg: c_int, func: F) -> Result<Arc<T>>where
T: Send + Sync + 'static,
E: Into<Box<dyn Error + Send + Sync + 'static>>,
F: FnOnce(ValueRef<'_>) -> Result<T, E>,
pub fn get_or_create_aux<T, E, F>(&self, arg: c_int, func: F) -> Result<Arc<T>>where T: Send + Sync + 'static, E: Into<Box<dyn Error + Send + Sync + 'static>>, F: FnOnce(ValueRef<'_>) -> Result<T, E>,
Fetch or insert the auxiliary data associated with a particular
parameter. This is intended to be an easier-to-use way of fetching it
compared to calling get_aux
and
set_aux
separately.
See https://www.sqlite.org/c3ref/get_auxdata.html
for a discussion of
this feature, or the unit tests of this module for an example.
sourcepub fn set_aux<T: Send + Sync + 'static>(
&self,
arg: c_int,
value: T
) -> Result<Arc<T>>
pub fn set_aux<T: Send + Sync + 'static>( &self, arg: c_int, value: T ) -> Result<Arc<T>>
Sets the auxiliary data associated with a particular parameter. See
https://www.sqlite.org/c3ref/get_auxdata.html
for a discussion of
this feature, or the unit tests of this module for an example.
sourcepub fn get_aux<T: Send + Sync + 'static>(
&self,
arg: c_int
) -> Result<Option<Arc<T>>>
pub fn get_aux<T: Send + Sync + 'static>( &self, arg: c_int ) -> Result<Option<Arc<T>>>
Gets the auxiliary data that was associated with a given parameter via
set_aux
. Returns Ok(None)
if no data has been
associated, and Ok(Some(v)) if it has. Returns an error if the
requested type does not match.
sourcepub unsafe fn get_connection(&self) -> Result<ConnectionRef<'_>>
pub unsafe fn get_connection(&self) -> Result<ConnectionRef<'_>>
Get the db connection handle via sqlite3_context_db_handle
Safety
This function is marked unsafe because there is a potential for other references to the connection to be sent across threads, see this comment.
sourcepub fn set_result_subtype(&self, sub_type: c_uint)
pub fn set_result_subtype(&self, sub_type: c_uint)
Set the Subtype of an SQL function