pub struct Cursor { /* private fields */ }Expand description
An iterator for result sets from MimerSQL databases.
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub fn set_scroll_option(&mut self, option: ScrollOption)
pub fn set_scroll_option(&mut self, option: ScrollOption)
Sets the scroll option for the cursor. Only avaiable for cursors on statements prepared as (scrollable)CursorMode::Scrollable. Valid options are ScrollOption::NEXT, ScrollOption::PREVIOUS, ScrollOption::FIRST, ScrollOption::LAST, ScrollOption::ABSOLUTE, ScrollOption::RELATIVE.
The options are configured as follows
- ScrollOption::NEXT - Moves the cursor to the next row in the result set.
- ScrollOption::PREVIOUS - Moves the cursor to the previous row in the result set.
- ScrollOption::FIRST - Moves the cursor to the first row in the result set.
- ScrollOption::LAST - Moves the cursor to the last row in the result set.
- ScrollOption::ABSOLUTE - Moves the cursor to the specified row in the result set. The row number is specified as a parameter to the scroll method.
- ScrollOption::RELATIVE - Moves the cursor to the specified row relative to the current row. The row number is specified as a parameter to the scroll method.
Sourcepub fn scroll(&mut self, idx: i32) -> Result<Option<&Row>, i32>
pub fn scroll(&mut self, idx: i32) -> Result<Option<&Row>, i32>
Moves cursor to specified row index. Takes into consideration the ScrollOption set for the cursor. The default scroll option is ScrollOption::NEXT. To change the scroll option use set_scroll_option.
§Errors
Returns Err when the cursor could not be moved to the specified row, e.g. if the specified index is out of bounds.
§Examples
let mut conn = Connection::open(db, ident, pass).unwrap();
let stmnt = conn.prepare("SELECT * FROM test_table", CursorMode::Scrollable).unwrap();
let mut cursor = stmnt.open_cursor().unwrap();
let row = cursor.scroll(2).unwrap().expect("Nothing was found on the specified index");Sourcepub fn next_row(&mut self) -> Result<Option<&Row>, i32>
pub fn next_row(&mut self) -> Result<Option<&Row>, i32>
Moves cursor to the next row in the result set and returns its contents. On success, returns either Some(Row) or None if there is no more data to fetch.
§Errors
Returns Err when cursor couldn’t advance.
§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");Sourcepub fn get_mode(&self) -> CursorMode
pub fn get_mode(&self) -> CursorMode
Returns the CursorMode of the Cursor.
Sourcepub fn check_is_mode(&self, mode: CursorMode) -> bool
pub fn check_is_mode(&self, mode: CursorMode) -> bool
Checks if the cursor’s mode matches a given CursorMode.
Sourcepub fn current_row(&self) -> Result<i32, i32>
pub fn current_row(&self) -> Result<i32, i32>
Returns current index
Sourcepub fn get_row_size(&self) -> Result<i32, i32>
pub fn get_row_size(&self) -> Result<i32, i32>
Returns the maximum number of bytes required to hold one row of data. This method might be used to calculate the maximum number of rows allowed in an array fetching scenario under certain memory restrictions.
Trait Implementations§
Source§impl FallibleStreamingIterator for Cursor
impl FallibleStreamingIterator for Cursor
Source§fn advance(&mut self) -> Result<(), Self::Error>
fn advance(&mut self) -> Result<(), Self::Error>
Source§fn next(&mut self) -> Result<Option<&Self::Item>, Self::Error>
fn next(&mut self) -> Result<Option<&Self::Item>, Self::Error>
Source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
Source§fn all<F>(&mut self, f: F) -> Result<bool, Self::Error>
fn all<F>(&mut self, f: F) -> Result<bool, Self::Error>
Source§fn any<F>(&mut self, f: F) -> Result<bool, Self::Error>
fn any<F>(&mut self, f: F) -> Result<bool, Self::Error>
Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Source§fn count(self) -> Result<usize, Self::Error>where
Self: Sized,
fn count(self) -> Result<usize, Self::Error>where
Self: Sized,
Source§fn filter<F>(self, f: F) -> Filter<Self, F>
fn filter<F>(self, f: F) -> Filter<Self, F>
Source§fn find<F>(&mut self, f: F) -> Result<Option<&Self::Item>, Self::Error>
fn find<F>(&mut self, f: F) -> Result<Option<&Self::Item>, Self::Error>
Source§fn for_each<F>(self, f: F) -> Result<(), Self::Error>
fn for_each<F>(self, f: F) -> Result<(), Self::Error>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
Source§fn map<F, B>(self, f: F) -> Map<Self, F, B>
fn map<F, B>(self, f: F) -> Map<Self, F, B>
Source§fn map_ref<F, B>(self, f: F) -> MapRef<Self, F>
fn map_ref<F, B>(self, f: F) -> MapRef<Self, F>
Source§fn map_err<F, B>(self, f: F) -> MapErr<Self, F>
fn map_err<F, B>(self, f: F) -> MapErr<Self, F>
Source§fn nth(&mut self, n: usize) -> Result<Option<&Self::Item>, Self::Error>
fn nth(&mut self, n: usize) -> Result<Option<&Self::Item>, Self::Error>
nth element of the iterator.Source§fn position<F>(&mut self, f: F) -> Result<Option<usize>, Self::Error>
fn position<F>(&mut self, f: F) -> Result<Option<usize>, Self::Error>
Source§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n elements.Source§fn skip_while<F>(self, f: F) -> SkipWhile<Self, F>
fn skip_while<F>(self, f: F) -> SkipWhile<Self, F>
Auto Trait Implementations§
impl Freeze for Cursor
impl !RefUnwindSafe for Cursor
impl Send for Cursor
impl Sync for Cursor
impl Unpin for Cursor
impl !UnwindSafe for Cursor
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
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>
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>
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