pub struct Row { /* private fields */ }Expand description
A single row returned from a query, with named columns.
Implementations§
Source§impl Row
impl Row
Sourcepub fn get(&self, col: &str) -> Option<&Value>
pub fn get(&self, col: &str) -> Option<&Value>
Look up a value by column name. Returns None if the column does not
exist in this row.
Sourcepub fn get_by_index(&self, i: usize) -> Option<&Value>
pub fn get_by_index(&self, i: usize) -> Option<&Value>
Look up a value by zero-based column index.
Sourcepub fn try_get<T: FromValue>(&self, col: &str) -> Result<T, OxiSqlError>
pub fn try_get<T: FromValue>(&self, col: &str) -> Result<T, OxiSqlError>
Type-safe extraction by column name.
Looks up the column and converts via FromValue. Returns
OxiSqlError::Other if the column does not exist, or
OxiSqlError::TypeMismatch if the value cannot be converted.
§Example
let row = Row::new(vec!["id".into()], vec![Value::I64(42)]);
let id: i64 = row.try_get("id").unwrap();
assert_eq!(id, 42);Sourcepub fn try_get_by_index<T: FromValue>(&self, i: usize) -> Result<T, OxiSqlError>
pub fn try_get_by_index<T: FromValue>(&self, i: usize) -> Result<T, OxiSqlError>
Type-safe extraction by column index.
Like try_get but uses a zero-based index.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Return the number of columns in this row.
Sourcepub fn is_null(&self, col: &str) -> bool
pub fn is_null(&self, col: &str) -> bool
Check whether a column value is NULL.
Returns true if the column exists and its value is Value::Null.
Returns false if the column does not exist or has a non-null value.
Sourcepub fn into_values(self) -> Vec<Value>
pub fn into_values(self) -> Vec<Value>
Consume the row and return its values, discarding column names.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Row
impl RefUnwindSafe for Row
impl Send for Row
impl Sync for Row
impl Unpin for Row
impl UnsafeUnpin for Row
impl UnwindSafe for Row
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more