Skip to main content

ColumnIndex

Trait ColumnIndex 

Source
pub trait ColumnIndex<T: ?Sized>: Debug {
    // Required method
    fn index(&self, container: &T) -> Result<usize, Error>;
}
Expand description

A type that can be used to index into a Row or Statement.

The get and try_get methods of Row accept any type that implements ColumnIndex. This trait is implemented for strings which are used to look up a column by name, and for usize which is used as a positional index into the row.

Caution: The column index may differ between a Statement and a Row returned by the statement. This can happen with some databases if, for example, the schema changes between prepare and execute or if the database does not provide column information when the statement is prepared.

Required Methods§

Source

fn index(&self, container: &T) -> Result<usize, Error>

Returns a valid positional index into the row or statement, ColumnIndexOutOfBounds, or, ColumnNotFound.

Implementations on Foreign Types§

Source§

impl<T: ?Sized, I: ColumnIndex<T> + ?Sized> ColumnIndex<T> for &I

Source§

fn index(&self, row: &T) -> Result<usize, Error>

Implementors§