Skip to main content

Context

Struct Context 

Source
pub struct Context<'a> { /* private fields */ }
Available on crate feature functions only.
Expand description

Context is a wrapper for the SQLite function evaluation context.

Implementations§

Source§

impl Context<'_>

Source

pub fn len(&self) -> usize

Returns the number of arguments to the function.

Source

pub fn is_empty(&self) -> bool

Returns true when there is no argument.

Source

pub fn get<T: FromSql>(&self, idx: usize) -> Result<T>

Returns the idxth 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.

Source

pub unsafe fn get_pointer<T: 'static>( &self, idx: usize, ptr_type: &'static CStr, ) -> Option<&T>

Available on crate feature pointer only.

Return raw pointer at idx

§Safety

This function is unsafe because it uses raw pointer and cast

Source

pub fn get_raw(&self, idx: usize) -> ValueRef<'_>

Returns the idxth argument as a ValueRef.

§Failure

Will panic if idx is greater than or equal to self.len().

Source

pub fn get_arg(&self, idx: usize) -> SqlFnArg

Returns the idxth argument as a SqlFnArg. To be used when the SQL function result is one of its arguments.

Source

pub fn get_subtype(&self, idx: usize) -> c_uint

Returns the subtype of idxth argument.

§Failure

Will panic if idx is greater than or equal to self.len().

Source

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.

§Failure

Will panic if arg is greater than or equal to self.len().

Source

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.

§Failure

Will panic if arg is greater than or equal to self.len().

Source

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.

§Failure

Will panic if arg is greater than or equal to self.len().

Source

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.

Auto Trait Implementations§

§

impl<'a> !Send for Context<'a>

§

impl<'a> !Sync for Context<'a>

§

impl<'a> Freeze for Context<'a>

§

impl<'a> RefUnwindSafe for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnsafeUnpin for Context<'a>

§

impl<'a> UnwindSafe for Context<'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, 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.