ResultRecord

Trait ResultRecord 

Source
pub trait ResultRecord: Sized {
    // Required method
    fn from_row(row: &Row<'_>) -> Result<Self>;
}
Expand description

This trait describes types that deserialize from a single row (tuple).

When derived on a struct, the rename_all (type-level) and rename and ignore (field-level) attributes work identically to those of Table; see its documentation for more details.

Required Methods§

Source

fn from_row(row: &Row<'_>) -> Result<Self>

Convert a dynamically-typed relational tuple to a statically-typed record.

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 ResultRecord for bool

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for f32

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for f64

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for i8

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for i16

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for i32

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for i64

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for isize

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for u8

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for u16

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for u32

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for u64

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for ()

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for usize

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for Box<str>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for Box<[u8]>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for Rc<str>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for Rc<[u8]>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for String

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for Arc<str>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for Arc<[u8]>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for Vec<u8>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroI8

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroI16

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroI32

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroI64

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroIsize

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroU8

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroU16

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroU32

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroU64

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl ResultRecord for NonZeroUsize

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where A: FromSql, B: FromSql, C: FromSql, D: FromSql, E: FromSql, F: FromSql, G: FromSql, H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where B: FromSql, C: FromSql, D: FromSql, E: FromSql, F: FromSql, G: FromSql, H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where C: FromSql, D: FromSql, E: FromSql, F: FromSql, G: FromSql, H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where D: FromSql, E: FromSql, F: FromSql, G: FromSql, H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where E: FromSql, F: FromSql, G: FromSql, H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where F: FromSql, G: FromSql, H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where G: FromSql, H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where H: FromSql, I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where I: FromSql, J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where J: FromSql, K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where K: FromSql, L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<K, V> ResultRecord for BTreeMap<K, V>
where K: Ord + for<'a> From<&'a str>, V: FromSql,

The ResultRecord impl for maps represents an arbitrary row as column names mapped to the corresponding column values. It works for however many columns; the .len() of the map will be the number of columns in the returned rows.

Note that this is not the same as the ResultSet impl for maps, which maps keys in the first column to values in the second column, and thus only works for queries returning exactly two-columns. See its documentation for a more detailed explanation.

use nanosql::Value;

define_query! {
    OneRowManyColumns<'p>: () => [BTreeMap<Box<str>, Value>; 1] {
        r#"
        WITH t("qux", "baz", "mem") AS (
            VALUES ('some string', 987, NULL)
        )
        SELECT
            "qux" AS "qux",
            "baz" AS "baz",
            "mem" AS "mem"
        FROM t;
        "#
    }
}
let conn = Connection::connect_in_memory()?;
let mut query = conn.compile(OneRowManyColumns)?;

assert_eq!(
    query.invoke(())?,
    [
        BTreeMap::from([
            ("baz".into(), Value::Integer(987)),
            ("qux".into(), Value::Text("some string".into())),
            ("mem".into(), Value::Null),
        ])
    ]
);
Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<K, V> ResultRecord for HashMap<K, V>
where K: Eq + Hash + for<'a> From<&'a str>, V: FromSql,

The ResultRecord impl for maps represents an arbitrary row as column names mapped to the corresponding column values. It works for however many columns; the .len() of the map will be the number of columns in the returned rows.

Note that this is not the same as the ResultSet impl for maps, which maps keys in the first column to values in the second column, and thus only works for queries returning exactly two-columns. See its documentation for a more detailed explanation.

use nanosql::Value;

define_query! {
    OneRowManyColumns<'p>: () => Vec<HashMap<String, Value>> {
        r#"
        WITH t("qux", "baz", "mem") AS (
            VALUES ('some string', 999, NULL)
        )
        SELECT
            "qux" AS "qux",
            "baz" AS "baz",
            "mem" AS "mem"
        FROM t;
        "#
    }
}
let conn = Connection::connect_in_memory()?;
let mut query = conn.compile(OneRowManyColumns)?;

assert_eq!(
    query.invoke(())?,
    [
        HashMap::from([
            ("baz".into(), Value::Integer(999)),
            ("qux".into(), Value::Text("some string".into())),
            ("mem".into(), Value::Null),
        ])
    ]
);
Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where L: FromSql, M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where M: FromSql, N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<N, O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
where N: FromSql, O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<O, P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (O, P, Q, R, S, T, U, V, W, X, Y, Z)
where O: FromSql, P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<P, Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (P, Q, R, S, T, U, V, W, X, Y, Z)
where P: FromSql, Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<Q, R, S, T, U, V, W, X, Y, Z> ResultRecord for (Q, R, S, T, U, V, W, X, Y, Z)
where Q: FromSql, R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<R, S, T, U, V, W, X, Y, Z> ResultRecord for (R, S, T, U, V, W, X, Y, Z)
where R: FromSql, S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<S, T, U, V, W, X, Y, Z> ResultRecord for (S, T, U, V, W, X, Y, Z)
where S: FromSql, T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<T> ResultRecord for Cow<'_, T>
where T: ?Sized + ToOwned, T::Owned: ResultRecord,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<T, U, V, W, X, Y, Z> ResultRecord for (T, U, V, W, X, Y, Z)
where T: FromSql, U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<T: FromSql> ResultRecord for Option<T>

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<U, V, W, X, Y, Z> ResultRecord for (U, V, W, X, Y, Z)
where U: FromSql, V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<V, W, X, Y, Z> ResultRecord for (V, W, X, Y, Z)
where V: FromSql, W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<W, X, Y, Z> ResultRecord for (W, X, Y, Z)
where W: FromSql, X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<X, Y, Z> ResultRecord for (X, Y, Z)
where X: FromSql, Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<Y, Z> ResultRecord for (Y, Z)
where Y: FromSql, Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<Z> ResultRecord for (Z,)
where Z: FromSql,

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Source§

impl<const N: usize> ResultRecord for [u8; N]

Source§

fn from_row(row: &Row<'_>) -> Result<Self>

Implementors§