Struct orm::Row
[−]
[src]
pub struct Row { /* 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); }).unwrap();
Methods
impl Row
[src]
pub fn len(&self) -> usize
[src]
Returns length of a row.
pub fn as_ref(&self, index: usize) -> Option<&Value>
[src]
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]
.
pub fn get<T, I>(&mut self, index: I) -> Option<T> where
I: ColumnIndex,
T: FromValue,
[src]
I: ColumnIndex,
T: FromValue,
Will copy value at index index
if it was not taken by Row::take
earlier,
then will convert it to T
.
pub fn get_opt<T, I>(&mut self, index: I) -> Option<Result<T, Error>> where
I: ColumnIndex,
T: FromValue,
[src]
I: ColumnIndex,
T: FromValue,
Will copy value at index index
if it was not taken by Row::take
or Row::take_opt
earlier, then will attempt convert it to T
. Unlike Row::get
, Row::get_opt
will
allow you to directly handle errors if the value could not be converted to T
.
pub fn take<T, I>(&mut self, index: I) -> Option<T> where
I: ColumnIndex,
T: FromValue,
[src]
I: ColumnIndex,
T: FromValue,
Will take value of a column with index index
if it exists and wasn't taken earlier then
will converts it to T
.
pub fn take_opt<T, I>(&mut self, index: I) -> Option<Result<T, Error>> where
I: ColumnIndex,
T: FromValue,
[src]
I: ColumnIndex,
T: FromValue,
Will take value of a column with index index
if it exists and wasn't taken earlier then
will attempt to convert it to T
. Unlike Row::take
, Row::take_opt
will allow you to
directly handle errors if the value could not be converted to T
.
pub fn unwrap(self) -> Vec<Value>
[src]
Trait Implementations
impl Index<usize> for Row
[src]
type Output = Value
The returned type after indexing.
fn index(&'a self, index: usize) -> &'a Value
[src]
Performs the indexing (container[index]
) operation.
impl<'a> Index<&'a str> for Row
[src]
type Output = Value
The returned type after indexing.
fn index(&'r self, index: &'a str) -> &'r Value
[src]
Performs the indexing (container[index]
) operation.
impl PartialEq<Row> for Row
[src]
fn eq(&self, __arg_0: &Row) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Row) -> bool
[src]
This method tests for !=
.
impl Debug for Row
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more