pub struct Row { /* private fields */ }Expand description
Represents a row in a result set.
Implementations§
source§impl Row
impl Row
sourcepub fn get_type(&self, idx: i16) -> Result<MimerDatatype<'_>, i32>
pub fn get_type(&self, idx: i16) -> Result<MimerDatatype<'_>, i32>
Gets the content from a specified index and returns a MimerDataType if successful.
§Errors
Returns Err when the column type couldn’t be determined.
§Examples
let mut conn = Connection::open(db, ident, pass).unwrap();
let stmnt = conn.prepare("SELECT * FROM test_table", CursorMode::Forward).unwrap();
let mut cursor = stmnt.open_cursor().unwrap();
let row = cursor.next_row().unwrap().expect("Nothing was found on this row");
let data_type = row.get_type(1).unwrap();sourcepub fn get<T: FromSql>(&self, idx: i16) -> Result<Option<T>, i32>
pub fn get<T: FromSql>(&self, idx: i16) -> Result<Option<T>, i32>
Gets the content from a specified index in a row using polymorphism.
Returns a Result of either Ok<Option<T>> or Err<i32> where T is the type specified and i32 is the error code.
If a null value is fetched, the return value will be Ok<None>.
§Errors
Returns Err when conversion to the specified type fails.
§Examples
let mut conn = Connection::open(db, ident, pass).unwrap();
let stmnt = conn.prepare("SELECT * FROM test_table", CursorMode::Forward).unwrap();
let mut cursor = stmnt.open_cursor().unwrap();
let row = cursor.next_row().unwrap().unwrap();
let str:String = row.get(1).unwrap().unwrap();sourcepub fn is_null(&self, idx: i16) -> Result<bool, i32>
pub fn is_null(&self, idx: i16) -> Result<bool, i32>
Checks if the value at the specified index is null.
§Examples
let mut conn = Connection::open(db, ident, pass).unwrap();
let stmnt = conn.prepare("INSERT INTO test_table (column_1) VALUES(?)", CursorMode::Forward).unwrap();
stmnt.execute_bind(&[&None::<String>]).unwrap(); // insert a null value
stmnt.execute_bind(&[&Some("Hello, World!".to_string())]).unwrap(); // insert a value that is not null
let stmnt = conn.prepare("SELECT * FROM test_table", CursorMode::Forward).unwrap();
let mut cursor = stmnt.open_cursor().unwrap();
let mut row = cursor.next_row().unwrap().unwrap();
assert!(row.is_null(1).unwrap()); // assert that the first value is null
row = cursor.next_row().unwrap().unwrap();
assert!(!row.is_null(1).unwrap()); // assert that the second value is not nullTrait 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 !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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more