Struct sqlite3_ext::ValueRef
source · #[repr(transparent)]pub struct ValueRef { /* private fields */ }
Expand description
A protected SQL value.
SQLite always owns all value objects. Consequently, this struct is never owned by Rust code, but instead always borrowed. A “protected” value means that SQLite holds a mutex for the lifetime of the reference.
SQLite automatically converts data to any requested type where possible. This conversion is
typically done in-place, which is why many of the conversion methods of this type require
&mut
.
Implementations§
source§impl ValueRef
impl ValueRef
sourcepub unsafe fn as_ptr(&self) -> *mut sqlite3_value
pub unsafe fn as_ptr(&self) -> *mut sqlite3_value
Get the underlying SQLite handle.
Safety
Invoking SQLite methods on the returned value may invalidate existing references previously returned by this object. This is safe as long as a mutable reference to this ValueRef is held.
sourcepub fn numeric_type(&mut self) -> ValueType
pub fn numeric_type(&mut self) -> ValueType
Attempt to convert the ValueRef to a numeric data type, and return the resulting data type. This conversion will only happen if it is losles, otherwise the underlying value will remain its original type.
sourcepub fn is_from_bind(&self) -> bool
pub fn is_from_bind(&self) -> bool
Returns true if this ValueRef originated from one of the sqlite3_bind interfaces. If it comes from an SQL literal value, or a table column, or an expression, then this method returns false.
Requires SQLite 3.28.0. On earlier versions, this method always returns false.
sourcepub fn nochange(&self) -> bool
pub fn nochange(&self) -> bool
Return true if the value is unchanged by an UPDATE operation. Specifically, this method is guaranteed to return true if all of the following are true:
- this ValueRef is a parameter to an UpdateVTab method;
- during the corresponding call to VTabCursor::column, ColumnContext::nochange returned true; and
- the column method failed with Error::NoChange.
If this method returns true under these circumstances, then the value will appear to be SQL NULL, and the UpdateVTab method must not change the underlying value.
Requires SQLite 3.22.0. On earlier versions of SQLite, this function will always return false.
sourcepub fn get_ref<T: 'static>(&self) -> Option<&T>
pub fn get_ref<T: 'static>(&self) -> Option<&T>
Get the PassedRef stored in this value.
This is a safe way of passing arbitrary Rust objects through SQLite, however it requires SQLite 3.20.0 to work. On older versions of SQLite, this function will always return None.
Requires SQLite 3.20.0. On earlier versions of SQLite, this function will always return None.
Trait Implementations§
source§impl FromValue for ValueRef
impl FromValue for ValueRef
source§fn value_type(&self) -> ValueType
fn value_type(&self) -> ValueType
source§fn is_null(&self) -> bool
fn is_null(&self) -> bool
self.value_type() == ValueType::Null
.source§fn try_get_blob(&self) -> Result<&[u8]>
fn try_get_blob(&self) -> Result<&[u8]>
source§fn try_get_str(&self) -> Result<&str>
fn try_get_str(&self) -> Result<&str>
source§impl PartialEq<ValueRef> for ValueRef
impl PartialEq<ValueRef> for ValueRef
impl<'a> ToContextResult for &'a ValueRef
Sets the context result to the contained value.
impl<'a> ToContextResult for &'a mut ValueRef
Sets the context result to the contained value.