pub trait Fetch<'r>: Sized {
type Value: Fetch<'r>;
// Required method
fn from_value(value: Self::Value) -> Result<Self>;
// Provided methods
fn fetch_column<'c>(
statement: &'r Statement<'c>,
column: ColumnIndex,
) -> Result<Self> { ... }
fn fetch_value<'c>(value: &'r ValueRef<'c>) -> Result<Self> { ... }
}Expand description
A value which can be read from a column or function argument.
Squire’s underlying ffi::Fetch trait is implemented for each type that
can be directly read through the SQLite C API. To implement
Fetch, set type Value to the actual column value (e.g., i64), and
implement from_value to translate from the stored column value to Self.
The lifetime parameter 'r represents the lifetime of the current row. Any
blob or text values borrowed from the current row must be
read or cloned before the query continues to the next row.
Required Associated Types§
Required Methods§
fn from_value(value: Self::Value) -> Result<Self>
Provided Methods§
fn fetch_column<'c>( statement: &'r Statement<'c>, column: ColumnIndex, ) -> Result<Self>
fn fetch_value<'c>(value: &'r ValueRef<'c>) -> Result<Self>
functions or value only.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 Fetch<'_> for SignedDuration
Available on crate feature jiff only.
impl Fetch<'_> for SignedDuration
jiff only.Source§impl<'b> Fetch<'b> for DateTime<FixedOffset>
Available on crate feature chrono only.
impl<'b> Fetch<'b> for DateTime<FixedOffset>
chrono only.Source§impl<'b> Fetch<'b> for NaiveDateTime
Available on crate feature chrono only.
impl<'b> Fetch<'b> for NaiveDateTime
chrono only.Source§impl<'r> Fetch<'r> for bool
Read the column as an i32 with
sqlite3_column_int; any nonzero value is
true, and 0 is false.
impl<'r> Fetch<'r> for bool
Read the column as an i32 with
sqlite3_column_int; any nonzero value is
true, and 0 is false.
Note that when applied to a column of a different data type, such as the
text 'true', SQLite may simply return 0, which Squire interprets as
false.
Source§impl<'r> Fetch<'r> for f32
Read the column as an f64 with sqlite3_column_double, and cast to
f32 with value as f32.
impl<'r> Fetch<'r> for f32
Read the column as an f64 with sqlite3_column_double, and cast to
f32 with value as f32.
If the value overflows an f32 (a previously finite
f64 became infinite), returns a range error.
Implementors§
Source§impl<'r, T> Fetch<'r> for Json<T>where
T: Deserialize<'r>,
Available on crate features json and serde only.
impl<'r, T> Fetch<'r> for Json<T>where
T: Deserialize<'r>,
json and serde only.