Struct postgres::rows::Row [] [src]

pub struct Row<'a> {
    // some fields omitted
}

A single result row of a query.

Methods

impl<'a> Row<'a>
[src]

fn len(&self) -> usize

Returns the number of values in the row.

fn columns(&self) -> &[Column]

Returns a slice describing the columns of the Row.

fn get<I, T>(&self, idx: I) -> T where I: RowIndex + Debug, T: FromSql

Retrieves the contents of a field of the row.

A field can be accessed by the name or index of its column, though access by index is more efficient. Rows are 0-indexed.

Panics

Panics if the index does not reference a column or the return type is not compatible with the Postgres type.

Example

let stmt = conn.prepare("SELECT foo, bar from BAZ").unwrap();
for row in &stmt.query(&[]).unwrap() {
    let foo: i32 = row.get(0);
    let bar: String = row.get("bar");
    println!("{}: {}", foo, bar);
}

fn get_opt<I, T>(&self, idx: I) -> Option<Result<T>> where I: RowIndex, T: FromSql

Retrieves the contents of a field of the row.

A field can be accessed by the name or index of its column, though access by index is more efficient. Rows are 0-indexed.

Returns None if the index does not reference a column, Some(Err(..)) if there was an error converting the result value, and Some(Ok(..)) on success.

fn get_bytes<I>(&self, idx: I) -> Option<&[u8]> where I: RowIndex + Debug

Retrieves the specified field as a raw buffer of Postgres data.

Panics

Panics if the index does not reference a column.

Trait Implementations

impl<'a> Debug for Row<'a>
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result

Formats the value using the given formatter.