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 method
    fn from_sqlite_null() -> Result<Self, DrizzleError> { ... }
}
Expand description

Trait for types that can be converted from SQLite values.

SQLite has 5 storage classes: NULL, INTEGER, REAL, TEXT, BLOB. This trait provides conversion methods for each type.

§Implementation Notes

  • Implement the methods that make sense for your type
  • Return Err for unsupported conversions
  • SQLiteEnum derive automatically implements this trait

Required Methods§

Source

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

Convert from a 64-bit integer value

Source

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

Convert from a text/string value

Source

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

Convert from a real/float value

Source

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

Convert from a blob/binary value

Provided Methods§

Source

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

Convert from a NULL value (default returns error)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

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 FromSQLiteValue for String

Source§

impl FromSQLiteValue for Vec<u8>

Source§

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

Implementors§