Skip to main content

FromSQLiteValue

Trait FromSQLiteValue 

Source
pub trait FromSQLiteValue: Sized {
    // Required methods
    fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError>;
    fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError>;
    fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError>;
    fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError>;

    // Provided methods
    fn from_sqlite_ref(value: SQLiteValueRef<'_>) -> Result<Self, DrizzleError> { ... }
    fn from_sqlite_null() -> Result<Self, DrizzleError> { ... }
}
Expand description

Decodes a Rust value from a SQLite value.

SQLite has five storage classes (NULL, INTEGER, REAL, TEXT, BLOB), and this trait has one method per class. Return DrizzleError::ConversionError from the ones your type does not accept. NULL is rejected unless you override from_sqlite_null, as Option<T> does.

Every DrizzleSQLiteColumn type (including #[derive(SQLiteEnum)] enums) gets this trait through a blanket impl, so implement DrizzleSQLiteColumn instead when the type is also used as a column.

Required Methods§

Source

fn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError>

Decodes an INTEGER.

§Errors

Returns DrizzleError::ConversionError if value cannot be represented as Self.

Source

fn from_sqlite_text(value: &str) -> Result<Self, DrizzleError>

Decodes a TEXT value.

§Errors

Returns DrizzleError::ConversionError if value cannot be parsed or represented as Self.

Source

fn from_sqlite_real(value: f64) -> Result<Self, DrizzleError>

Decodes a REAL value.

§Errors

Returns DrizzleError::ConversionError if value cannot be represented as Self.

Source

fn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError>

Decodes a BLOB.

§Errors

Returns DrizzleError::ConversionError if value cannot be interpreted as Self.

Provided Methods§

Source

fn from_sqlite_ref(value: SQLiteValueRef<'_>) -> Result<Self, DrizzleError>

Decodes any borrowed value by calling the method for its storage class.

§Errors

Returns DrizzleError::ConversionError if value cannot be represented as Self.

Source

fn from_sqlite_null() -> Result<Self, DrizzleError>

Decodes NULL.

§Errors

The default implementation always returns DrizzleError::ConversionError; override for nullable-aware types (e.g. Option).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromSQLiteValue for Arc<String>

Source§

impl FromSQLiteValue for Arc<Vec<u8>>

Source§

impl FromSQLiteValue for Arc<str>

Source§

impl FromSQLiteValue for Box<String>

Source§

impl FromSQLiteValue for Box<Vec<u8>>

Source§

impl FromSQLiteValue for Box<str>

Source§

impl FromSQLiteValue for CompactString

Source§

impl FromSQLiteValue for Rc<String>

Source§

impl FromSQLiteValue for Rc<Vec<u8>>

Source§

impl FromSQLiteValue for Rc<str>

Source§

impl FromSQLiteValue for String

Source§

impl FromSQLiteValue for Vec<u8>

Source§

impl FromSQLiteValue for bool

Source§

impl FromSQLiteValue for f32

Source§

impl FromSQLiteValue for f64

Source§

impl FromSQLiteValue for i8

Source§

impl FromSQLiteValue for i16

Source§

impl FromSQLiteValue for i32

Source§

impl FromSQLiteValue for i64

Source§

impl FromSQLiteValue for isize

Source§

impl FromSQLiteValue for u8

Source§

impl FromSQLiteValue for u16

Source§

impl FromSQLiteValue for u32

Source§

impl FromSQLiteValue for u64

Source§

impl FromSQLiteValue for usize

Source§

impl<T: FromSQLiteValue> FromSQLiteValue for Option<T>

Implementors§