Struct mysql::Row [] [src]

pub struct Row {
    // some fields omitted
}

Mysql row representation.

It allows you to move column values out of a row with Row::take method but note that it makes row incomplete. Calls to from_row_opt on incomplete row will return Error::FromRowError and also numerical indexing on taken columns will panic.

pool.prep_exec("SELECT * FROM tmp.Users", ()).map(|mut result| {
    let mut row = result.next().unwrap().unwrap();
    let id: u32 = row.take("id").unwrap();
    let name: String = row.take("name").unwrap();
    let age: u32 = row.take("age").unwrap();
    let email: String = row.take("email").unwrap();

    assert_eq!(1, id);
    assert_eq!("John", name);
    assert_eq!(17, age);
    assert_eq!("foo@bar.baz", email);
});

Methods

impl Row

fn len(&self) -> usize

Returns length of a row.

fn as_ref(&self, index: usize) -> Option<&Value>

Returns reference to the value of a column with index index if it exists and wasn't taken by Row::take method.

Non panicking version of row[usize].

fn get<T, I>(&mut self, index: I) -> Option<T> where T: FromValue, I: ColumnIndex

Will copy value at index index if it was not taken by Row::take earlier, then will convert it to T.

fn take<T, I>(&mut self, index: I) -> Option<T> where T: FromValue, I: ColumnIndex

Will take value of a column with index index if it exists and wasn't taken earlier then will converts it to T.

fn unwrap(self) -> Vec<Value>

Unwraps values of a row.

Panics

Panics if any of columns was taken by take method.

Trait Implementations

impl Index<usize> for Row

type Output = Value

fn index<'a>(&'a self, index: usize) -> &'a Value

impl<'a> Index<&'a str> for Row

type Output = Value

fn index<'r>(&'r self, index: &'a str) -> &'r Value

Derived Implementations

impl Debug for Row

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

impl PartialEq for Row

fn eq(&self, __arg_0: &Row) -> bool

fn ne(&self, __arg_0: &Row) -> bool

impl Clone for Row

fn clone(&self) -> Row

fn clone_from(&mut self, source: &Self)