Struct Index

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

Wrapper for IDBIndex, for use in transactions

Most of the functions here take a JsValue as the key(s) to use in the index. If the index was built with a compound key, then you should use eg. js_sys::Array::from_iter([key_1, key_2]) as the key.

Implementations§

Source§

impl<Err> Index<Err>

Source

pub fn contains(&self, key: &JsValue) -> impl Future<Output = Result<bool, Err>>

Checks whether the provided key (for this index) already exists

Internally, this uses IDBIndex::count.

Source

pub fn count_in( &self, range: impl RangeBounds<JsValue>, ) -> impl Future<Output = Result<usize, Err>>

Count all the keys (for this index) in the provided range

Internally, this uses IDBIndex::count.

Source

pub fn get( &self, key: &JsValue, ) -> impl Future<Output = Result<Option<JsValue>, Err>>

Get the object with key key for this index

Internally, this uses IDBIndex::get.

Source

pub fn get_first_in( &self, range: impl RangeBounds<JsValue>, ) -> impl Future<Output = Result<Option<JsValue>, Err>>

Get the first value with a key (for this index) in range, ordered by key (for this index)

Note that the unbounded range is not a valid range for IndexedDB.

Internally, this uses IDBIndex::get.

Source

pub fn get_all( &self, limit: Option<u32>, ) -> impl Future<Output = Result<Vec<JsValue>, Err>>

Get all the objects in the store, ordered by this index, with a maximum number of results of limit

Internally, this uses IDBIndex::getAll.

Source

pub fn get_all_in( &self, range: impl RangeBounds<JsValue>, limit: Option<u32>, ) -> impl Future<Output = Result<Vec<JsValue>, Err>>

Get all the objects with a key (for this index) in the provided range, with a maximum number of results of limit, ordered by this index

Internally, this uses IDBIndex::getAll.

Source

pub fn get_first_key_in( &self, range: impl RangeBounds<JsValue>, ) -> impl Future<Output = Result<Option<JsValue>, Err>>

Get the first existing primary key for an object that has a key (for this index) in the provided range

Internally, this uses IDBIndex::getKey.

Source

pub fn get_all_keys( &self, limit: Option<u32>, ) -> impl Future<Output = Result<Vec<JsValue>, Err>>

List all the primary keys in the object store, with a maximum number of results of limit, ordered by this index

Internally, this uses IDBIndex::getAllKeys.

Source

pub fn get_all_keys_in( &self, range: impl RangeBounds<JsValue>, limit: Option<u32>, ) -> impl Future<Output = Result<Vec<JsValue>, Err>>

List all the primary keys of objects with a key (for this index)in the provided range, with a maximum number of results of limit, ordered by this index

Internally, this uses IDBIndex::getAllKeys.

Source

pub fn cursor(&self) -> CursorBuilder<Err>

Open a Cursor on this index

Auto Trait Implementations§

§

impl<Err> Freeze for Index<Err>

§

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

§

impl<Err> !Send for Index<Err>

§

impl<Err> !Sync for Index<Err>

§

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

§

impl<Err> UnwindSafe for Index<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.