Skip to main content

Table

Trait Table 

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

    // Provided methods
    fn rows<'stmt, P: Params>(
        stmt: &'stmt mut Statement<'_>,
        params: P,
    ) -> Result<impl Iterator<Item = Result<Self, TableError>> + 'stmt, TableError>
       where Self: 'stmt { ... }
    fn row<P: Params>(
        stmt: &mut Statement<'_>,
        params: P,
    ) -> Result<Self, TableError> { ... }
}
Expand description

Deserialize a database record from a stepped SQLite row.

Implement from_row, then use rows and row with any statement that selects the table’s columns.

Required Methods§

Source

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

Deserialize a single row into Self. Returns rusqlite::Result for direct use inside rusqlite::query_map / query_row callbacks. For high-level iteration, prefer Table::rows or Table::row.

Provided Methods§

Source

fn rows<'stmt, P: Params>( stmt: &'stmt mut Statement<'_>, params: P, ) -> Result<impl Iterator<Item = Result<Self, TableError>> + 'stmt, TableError>
where Self: 'stmt,

Iterate over the results of stmt, deserializing each row through from_row. Return TableError for both fetch and deserialization failures. Pass either a rusqlite::Statement or a rusqlite::CachedStatement (via deref coercion).

Source

fn row<P: Params>( stmt: &mut Statement<'_>, params: P, ) -> Result<Self, TableError>

Fetch exactly one row from stmt. Returns TableError::QueryError if the row is missing or fails to deserialize. Accepts both rusqlite::Statement and rusqlite::CachedStatement (the latter via deref coercion).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§