Struct ValueRef

Source
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

Source

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.

Source

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.

Source

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.

Source

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:

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.

Source

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 AsMut<ValueRef> for Column

Source§

fn as_mut(&mut self) -> &mut ValueRef

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<ValueRef> for Column

Source§

fn as_ref(&self) -> &ValueRef

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for ValueRef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FromValue for ValueRef

Source§

fn value_type(&self) -> ValueType

Returns the data type of the ValueRef. Note that calling get methods on the ValueRef may cause a conversion to a different data type, but this is not guaranteed.
Source§

fn get_i32(&self) -> i32

Interpret this value as i32.
Source§

fn get_i64(&self) -> i64

Interpret this value as i64.
Source§

fn get_f64(&self) -> f64

Interpret this value as f64.
Source§

unsafe fn get_blob_unchecked(&self) -> &[u8]

Get the bytes of this BLOB value. Read more
Source§

fn get_blob(&mut self) -> Result<&[u8]>

Interpret this value as a BLOB.
Source§

fn is_null(&self) -> bool

Convenience method equivalent to self.value_type() == ValueType::Null.
Source§

fn try_get_blob(&self) -> Result<&[u8]>

Attempt to interpret this value as a BLOB, without converting. If the underlying data type is not a BLOB, this function will fail with Err(SQLITE_MISMATCH).
Source§

unsafe fn get_str_unchecked(&self) -> Result<&str>

Get the underlying TEXT value. Read more
Source§

fn get_str(&mut self) -> Result<&str>

Interpret the value as TEXT. Read more
Source§

fn try_get_str(&self) -> Result<&str>

Attempt to interpret this value as TEXT, without converting. If the underlying data type is not TEXT, this function will fail with Err(SQLITE_MISMATCH). This function can also fail if the string has invalid UTF-8.
Source§

fn to_owned(&self) -> Result<Value>

Clone the value, returning a Value.
Source§

impl PartialEq for ValueRef

Source§

fn eq(&self, other: &Self) -> bool

Compare the underlying values of two ValueRefs. This function follows SQL equality semantics, meaning that NULL != NULL.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> ToParam for &'a ValueRef

Source§

fn bind_param(self, stmt: &mut Statement, pos: i32) -> Result<()>

Bind this value to the prepared Statement at the provided position. Read more
Source§

impl ToParam for &mut ValueRef

Source§

fn bind_param(self, stmt: &mut Statement, pos: i32) -> Result<()>

Bind this value to the prepared Statement at the provided position. Read more
Source§

impl<'a> ToContextResult for &'a ValueRef

Sets the context result to the contained value.

Source§

impl<'a> ToContextResult for &'a mut ValueRef

Sets the context result to the contained value.

Auto Trait Implementations§

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.