Struct Value

Source
pub struct Value { /* private fields */ }
Expand description

Ergonomic wrapper around a raw sqlite3_value. It is the caller’s reponsibility to ensure that a given pointer points to a valid sqlite3_value object. There seems to be a 5-10% perf cost when using Value vs calling functions on raw pointers

Implementations§

Source§

impl Value

Source

pub fn from(value: &*mut sqlite3_value) -> Result<Value>

Create a Value struct from a borrowed sqlite3_value pointer

Source

pub fn at(values: &[*mut sqlite3_value], at: usize) -> Option<Value>

Create a Value struct from a sqlite3_value pointer slice at the given index.

Source

pub fn notnull_or(&self, error: Error) -> Result<&Self>

Ensure that the value’s type isn’t SQLITE_NULL - return the given error as an Err.

Source

pub fn notnull_or_else<F>(&self, err: F) -> Result<&Self>
where F: FnOnce() -> Error,

Ensure that the value’s type isn’t SQLITE_NULL - otherwise call the error function and return as Err.

Source

pub fn text_or_else<F>(&self, error: F) -> Result<&str>
where F: FnOnce(Error) -> Error,

Returns the UTF8 representation of the underlying sqlite_value. Fails if the value type is SQLITE_NULL, or if there’s a UTF8 error on the resulting string.

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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.