1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! FromRow trait for mapping database rows to Rust structs
use crateResult;
use crateValue;
/// A database row that can be queried by column name.
///
/// This trait abstracts over different database row implementations,
/// allowing the same `FromRow` implementations to work with different
/// database backends.
/// Extension trait for typed access to row values.
// Implement RowExt for all Row types
/// Trait for types that can be constructed from a database row.
///
/// This trait is typically implemented via the `#[derive(FromRow)]` macro,
/// which generates the implementation automatically based on struct fields.
///
/// # Manual Implementation
///
/// ```ignore
/// use rdbi::{FromRow, Row, RowExt, Result};
///
/// pub struct User {
/// pub id: i64,
/// pub username: String,
/// }
///
/// impl FromRow for User {
/// fn from_row<R: Row>(row: &R) -> Result<Self> {
/// Ok(Self {
/// id: row.get("id")?,
/// username: row.get("username")?,
/// })
/// }
///
/// fn column_names() -> &'static [&'static str] {
/// &["id", "username"]
/// }
/// }
/// ```