Struct Cursor

Source
pub struct Cursor<Err> { /* private fields */ }
Expand description

Wrapper for IDBCursorWithValue

Implementations§

Source§

impl<Err> Cursor<Err>

Source

pub fn value(&self) -> Option<JsValue>

Retrieve the value this Cursor is currently pointing at, or None if the cursor is completed

If this cursor was opened as a key-only cursor, then trying to call this method will panic.

Internally, this uses the IDBCursorWithValue::value property.

Source

pub fn key(&self) -> Option<JsValue>

Retrieve the key this Cursor is currently pointing at, or None if the cursor is completed

Internally, this uses the IDBCursor::key property.

Source

pub fn primary_key(&self) -> Option<JsValue>

Retrieve the primary key this Cursor is currently pointing at, or None if the cursor is completed

Internally, this uses the IDBCursor::primaryKey property.

Source

pub async fn advance(&mut self, count: u32) -> Result<(), Err>

Advance this Cursor by count elements

Internally, this uses IDBCursor::advance.

Source

pub async fn advance_until(&mut self, key: &JsValue) -> Result<(), Err>

Advance this Cursor until the provided key

Internally, this uses IDBCursor::continue.

Source

pub async fn advance_until_primary_key( &mut self, index_key: &JsValue, primary_key: &JsValue, ) -> Result<(), Err>

Advance this Cursor until the provided primary key

This is a helper function for cursors built on top of Indexes. It allows for quick resumption of index walking, faster than Cursor::advance_until if the primary key for the wanted element is known.

Note that this method does not work on cursors over object stores, nor on cursors which are set with a direction of anything other than Next or Prev.

Internally, this uses IDBCursor::continuePrimaryKey.

Source

pub async fn delete(&self) -> Result<(), Err>

Deletes the value currently pointed by this Cursor

Note that this method does not work on key-only cursors over indexes.

Internally, this uses IDBCursor::delete.

Source

pub async fn update(&self, value: &JsValue) -> Result<(), Err>

Update the value currently pointed by this Cursor to value

Note that this method does not work on key-only cursors over indexes.

Internally, this uses IDBCursor::update.

Auto Trait Implementations§

§

impl<Err> Freeze for Cursor<Err>

§

impl<Err> RefUnwindSafe for Cursor<Err>
where Err: RefUnwindSafe,

§

impl<Err> !Send for Cursor<Err>

§

impl<Err> !Sync for Cursor<Err>

§

impl<Err> Unpin for Cursor<Err>
where Err: Unpin,

§

impl<Err> UnwindSafe for Cursor<Err>
where Err: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.