AuthClientStorage

Trait AuthClientStorage 

Source
pub trait AuthClientStorage: Send {
    // Required methods
    fn get<'a>(
        &'a mut self,
        key: &'a str,
    ) -> BoxFuture<'a, Result<Option<StoredKey>, StorageError>>;
    fn set<'a>(
        &'a mut self,
        key: &'a str,
        value: StoredKey,
    ) -> BoxFuture<'a, Result<(), StorageError>>;
    fn remove<'a>(
        &'a mut self,
        key: &'a str,
    ) -> BoxFuture<'a, Result<(), StorageError>>;
}
Available on crate feature wasm-js only.
Expand description

Trait for persisting user authentication data.

Required Methods§

Source

fn get<'a>( &'a mut self, key: &'a str, ) -> BoxFuture<'a, Result<Option<StoredKey>, StorageError>>

Retrieves a stored value by key from the storage backend.

§Parameters
  • key: The key to retrieve the value for. The key will be prefixed with the storage prefix.
§Returns

Returns Ok(Some(StoredKey)) if the key exists in storage, Ok(None) if not, or Err(StorageError) if there was an error accessing the storage.

Source

fn set<'a>( &'a mut self, key: &'a str, value: StoredKey, ) -> BoxFuture<'a, Result<(), StorageError>>

Stores a value with the given key in the storage backend.

§Parameters
  • key: The key to store the value under. The key will be prefixed with the storage prefix.
  • value: The value to store, which will be encoded before storage.
§Returns

Returns Ok(()) if the value was successfully stored, or Err(StorageError) if there was an error accessing the storage or storing the value.

Source

fn remove<'a>( &'a mut self, key: &'a str, ) -> BoxFuture<'a, Result<(), StorageError>>

Removes a stored value by key from the storage backend.

§Parameters
  • key: The key to remove from storage. The key will be prefixed with the storage prefix.
§Returns

Returns Ok(()) if the key was successfully removed or didn’t exist, or Err(StorageError) if there was an error accessing the storage.

Trait Implementations§

Source§

impl From<LocalStorage> for Box<dyn AuthClientStorage>

Source§

fn from(storage: LocalStorage) -> Self

Converts to this type from the input type.

Implementors§