Skip to main content

FromValue

Trait FromValue 

Source
pub trait FromValue {
    // Required methods
    fn value_type(&self) -> ValueType;
    fn get_i32(&self) -> i32;
    fn get_i64(&self) -> i64;
    fn get_f64(&self) -> f64;
    unsafe fn get_blob_unchecked(&self) -> &[u8] ;
    fn get_blob(&mut self) -> Result<&[u8]>;

    // Provided methods
    fn is_null(&self) -> bool { ... }
    fn try_get_blob(&self) -> Result<&[u8]> { ... }
    unsafe fn get_str_unchecked(&self) -> Result<&str> { ... }
    fn get_str(&mut self) -> Result<&str> { ... }
    fn try_get_str(&self) -> Result<&str> { ... }
    fn to_owned(&self) -> Result<Value> { ... }
}
Expand description

Allows access to an underlying SQLite value.

Required Methods§

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.

§Safety

If the type of this value is not BLOB, the behavior of this function is undefined.

Source

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

Interpret this value as a BLOB.

Provided Methods§

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.

This method will fail if the value has invalid UTF-8.

§Safety

If the type of this value is not TEXT, the behavior of this function is undefined.

Source

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

Interpret the value as TEXT.

This method will fail if SQLite runs out of memory while converting the value, or if the value has invalid UTF-8.

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.

Implementors§