pub struct SqliteValue(/* private fields */);_sqlite only.Expand description
An owned handle to a sqlite3_value.
ยงNote: Decoding is Stateful
The sqlite3_value interface reserves the right to be stateful:
Other interfaces might change the datatype for an sqlite3_value object. For example, if the datatype is initially SQLITE_INTEGER and sqlite3_value_text(V) is called to extract a text value for that integer, then subsequent calls to sqlite3_value_type(V) might return SQLITE_TEXT. Whether or not a persistent internal datatype conversion occurs is undefined and may change from one release of SQLite to the next.
Thus, this type is !Sync and SqliteValueRef is !Send and !Sync to prevent data races.
Additionally, this statefulness means that the return values of sqlite3_value_bytes() and
sqlite3_value_blob() could be invalidated by later calls to other sqlite3_value* methods.
To prevent undefined behavior from accessing dangling pointers, this type (and any
SqliteValueRef instances created from it) remembers when it was used to decode a
borrowed &[u8] or &str and returns an error if it is used to decode any other type.
To bypass this error, you must prove that no outstanding borrows exist.
This may be done in one of a few ways:
- If you hold mutable access, call
Self::reset_borrow()which resets the borrowed state. - If you have an immutable reference, call
Self::clone()to get a new instance with no outstanding borrows. - If you hold a
SqliteValueRef, callSqliteValueRef::to_owned()to get a newSqliteValuewith no outstanding borrows.
This is only necessary if using the same SqliteValue or SqliteValueRef to decode
multiple different types. The vast majority of use-cases employing once-through decoding
should not have to worry about this.
Implementationsยง
Sourceยงimpl SqliteValue
impl SqliteValue
Sourcepub fn reset_borrow(&mut self)
pub fn reset_borrow(&mut self)
Prove that there are no outstanding borrows of this instance.
Call this after decoding a borrowed &[u8] or &str
to reset the internal borrowed state and allow decoding of other types.
Sourcepub fn try_clone(&self) -> Result<SqliteValue, SqliteError>
pub fn try_clone(&self) -> Result<SqliteValue, SqliteError>
Call sqlite3_value_dup() to create a new instance of this type.
Returns an error if the call returns a null pointer, indicating that SQLite was unable to allocate the additional memory required.
Non-panicking version of Self::clone().
Trait Implementationsยง
Sourceยงimpl Clone for SqliteValue
impl Clone for SqliteValue
Sourceยงfn clone(&self) -> SqliteValue
fn clone(&self) -> SqliteValue
Call sqlite3_value_dup() to create a new instance of this type.
ยงPanics
If sqlite3_value_dup() returns a null pointer, indicating an out-of-memory condition.
See Self::try_clone() for a non-panicking version.
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl Value for SqliteValue
impl Value for SqliteValue
type Database = Sqlite
Sourceยงfn as_ref(&self) -> SqliteValueRef<'_>
fn as_ref(&self) -> SqliteValueRef<'_>
Sourceยงfn type_info(&self) -> Cow<'_, SqliteTypeInfo>
fn type_info(&self) -> Cow<'_, SqliteTypeInfo>
Sourceยงfn decode_unchecked<'r, T>(&'r self) -> T
fn decode_unchecked<'r, T>(&'r self) -> T
Auto Trait Implementationsยง
impl !Freeze for SqliteValue
impl !RefUnwindSafe for SqliteValue
impl Send for SqliteValue
impl !Sync for SqliteValue
impl Unpin for SqliteValue
impl UnwindSafe for SqliteValue
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
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more