Skip to main content

Fetch

Trait Fetch 

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

Source

type Value: Fetch<'r>

Required Methods§

Source

fn from_value(value: Self::Value) -> Result<Self>

Provided Methods§

Source

fn fetch_column<'c>( statement: &'r Statement<'c>, column: ColumnIndex, ) -> Result<Self>

Source

fn fetch_value<'c>(value: &'r ValueRef<'c>) -> Result<Self>

Available on crate features 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 TimeDelta

Available on crate feature chrono only.
Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl Fetch<'_> for SignedDuration

Available on crate feature jiff only.
Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl Fetch<'_> for Timestamp

Available on crate feature jiff only.
Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for DateTime<FixedOffset>

Available on crate feature chrono only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for DateTime<Utc>

Available on crate feature chrono only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for NaiveDate

Available on crate feature chrono only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for NaiveDateTime

Available on crate feature chrono only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for NaiveTime

Available on crate feature chrono only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for Date

Available on crate feature jiff only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for DateTime

Available on crate feature jiff only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for Time

Available on crate feature jiff only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for Span

Available on crate feature jiff only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for Zoned

Available on crate feature jiff only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for Url

Available on crate feature url only.
Source§

type Value = Borrowed<'b, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'b> Fetch<'b> for Uuid

Available on crate feature uuid only.
Source§

type Value = Borrowed<'b, [u8]>

Source§

fn from_value(value: Self::Value) -> Result<Self>

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.

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§

type Value = i32

Source§

fn from_value(value: Self::Value) -> Result<Self>

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.

If the value overflows an f32 (a previously finite f64 became infinite), returns a range error.

Source§

type Value = f64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for f64

Source§

type Value = f64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for i8

Source§

type Value = i32

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for i16

Source§

type Value = i32

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for i32

Source§

type Value = i32

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for i64

Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for isize

Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for u8

Source§

type Value = i32

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for u16

Source§

type Value = i32

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for u32

Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for u64

Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for usize

Source§

type Value = i64

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for String

Source§

type Value = Borrowed<'r, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r> Fetch<'r> for Vec<u8>

Source§

type Value = Borrowed<'r, [u8]>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r, 'a> Fetch<'r> for &'a str
where 'r: 'a,

Source§

type Value = Borrowed<'r, str>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r, 'a> Fetch<'r> for &'a [u8]
where 'r: 'a,

Source§

type Value = Borrowed<'r, [u8]>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Source§

impl<'r, T> Fetch<'r> for Option<T>
where T: Fetch<'r>,

Source§

type Value = Option<<T as Fetch<'r>>::Value>

Source§

fn from_value(value: Self::Value) -> Result<Self>

Implementors§

Source§

impl<'r> Fetch<'r> for Type

Source§

impl<'r> Fetch<'r> for RowId

Source§

impl<'r, T> Fetch<'r> for Json<T>
where T: Deserialize<'r>,

Available on crate features json and serde only.
Source§

impl<'r, T> Fetch<'r> for Jsonb<T>
where T: Deserialize<'r>,

Available on crate features jsonb and serde only.
Source§

type Value = Borrowed<'r, [u8]>