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§
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 NonZeroI16
impl ResultRecord for NonZeroI16
Source§impl ResultRecord for NonZeroI32
impl ResultRecord for NonZeroI32
Source§impl ResultRecord for NonZeroI64
impl ResultRecord for NonZeroI64
Source§impl ResultRecord for NonZeroIsize
impl ResultRecord for NonZeroIsize
Source§impl ResultRecord for NonZeroU16
impl ResultRecord for NonZeroU16
Source§impl ResultRecord for NonZeroU32
impl ResultRecord for NonZeroU32
Source§impl ResultRecord for NonZeroU64
impl ResultRecord for NonZeroU64
Source§impl ResultRecord for NonZeroUsize
impl ResultRecord for NonZeroUsize
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,
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§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,
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§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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Source§impl<K, V> ResultRecord for BTreeMap<K, V>
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.
impl<K, V> ResultRecord for BTreeMap<K, V>
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§impl<K, V> ResultRecord for HashMap<K, V>
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.
impl<K, V> ResultRecord for HashMap<K, V>
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),
])
]
);