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

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.

§Errors

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

Source

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

Convert from a text/string value.

§Errors

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

Source

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

Convert from a real/float value.

§Errors

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

Source

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

Convert from a blob/binary value.

§Errors

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

Provided Methods§

Source

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

Convert from a borrowed SQLite storage value.

§Errors

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

Source

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

Convert from a NULL value (default returns error).

§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§