pub struct Context { /* private fields */ }Expand description
Describes the run-time environment of an application-defined function.
Implementations§
Source§impl Context
impl Context
Sourcepub fn db(&self) -> &Connection
pub fn db(&self) -> &Connection
Return a handle to the current database.
Sourcepub fn aux_data<T: 'static>(&self, idx: usize) -> Option<&mut T>
pub fn aux_data<T: 'static>(&self, idx: usize) -> Option<&mut T>
Retrieve data about a function parameter that was previously set with set_aux_data.
This method returns None if T is different from the data type that was stored previously.
Sourcepub fn set_aux_data<T: 'static>(&self, idx: usize, val: T)
pub fn set_aux_data<T: 'static>(&self, idx: usize, val: T)
Set the auxiliary data associated with the corresponding function parameter.
If some processing is necessary in order for a function parameter to be useful (for example, compiling a regular expression), this method can be used to cache the processed value in case it is later reused in the same query. The cached value can be retrieved with the aux_data method.
Sourcepub fn set_result(&self, val: impl ToContextResult) -> Result<()>
pub fn set_result(&self, val: impl ToContextResult) -> Result<()>
Assign the given value to the result of the function. This function always returns Ok.
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl UnwindSafe for Context
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