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
Errfor unsupported conversions SQLiteEnumderive automatically implements this trait
Required Methods§
Sourcefn from_sqlite_integer(value: i64) -> Result<Self, DrizzleError>
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.
Sourcefn from_sqlite_text(value: &str) -> Result<Self, DrizzleError>
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.
Sourcefn from_sqlite_real(value: f64) -> Result<Self, DrizzleError>
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.
Sourcefn from_sqlite_blob(value: &[u8]) -> Result<Self, DrizzleError>
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§
Sourcefn from_sqlite_null() -> Result<Self, DrizzleError>
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".