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§

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.

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.

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.

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.

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§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Formats the value using the given formatter. Read more
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. Read more
Interpret this value as i32.
Interpret this value as i64.
Interpret this value as f64.
Get the bytes of this BLOB value. Read more
Interpret this value as a BLOB.
Convenience method equivalent to self.value_type() == ValueType::Null.
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). Read more
Get the underlying TEXT value. Read more
Interpret the value as TEXT. Read more
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. Read more
Clone the value, returning a Value.

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Bind this value to the prepared Statement at the provided position. Read more
Bind this value to the prepared Statement at the provided position. Read more

Sets the context result to the contained value.

Sets the context result to the contained value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.