pub struct LocalStorage;Expand description
Async accessor for the Chrome extension storage.local area.
Implementations§
Source§impl LocalStorage
impl LocalStorage
Sourcepub async fn set_item(key: &str, value: &str) -> Result<JsValue, JsValue>
pub async fn set_item(key: &str, value: &str) -> Result<JsValue, JsValue>
Stores value under key, overwriting any existing value.
Sourcepub async fn get_item(key: &str) -> Result<Option<String>, JsValue>
pub async fn get_item(key: &str) -> Result<Option<String>, JsValue>
Retrieves the value stored under key, or None if it is not present.
Sourcepub async fn get_items(keys: Vec<&str>) -> Result<StorageData, JsValue>
pub async fn get_items(keys: Vec<&str>) -> Result<StorageData, JsValue>
Retrieves the items stored under the given keys as StorageData.
Sourcepub async fn get_all() -> Result<StorageData, JsValue>
pub async fn get_all() -> Result<StorageData, JsValue>
Retrieves all items from extension storage as StorageData.
Sourcepub async fn keys() -> Result<Vec<String>, JsValue>
pub async fn keys() -> Result<Vec<String>, JsValue>
Returns the keys of all items currently in extension storage.
Sourcepub async fn rename_item(from_key: &str, to_key: &str) -> Result<(), Error>
pub async fn rename_item(from_key: &str, to_key: &str) -> Result<(), Error>
Renames a stored item from from_key to to_key. Errors with
Error::KeyExists if to_key is already present, or
Error::MissingKey if from_key does not exist.
Sourcepub async fn remove_items(keys: Vec<&str>) -> Result<(), JsValue>
pub async fn remove_items(keys: Vec<&str>) -> Result<(), JsValue>
Removes the items stored under each of the given keys.
Sourcepub async fn unit_tests() -> Result<(), String>
pub async fn unit_tests() -> Result<(), String>
Runs the storage unit test suite, preserving and restoring any pre-existing storage contents around the test and reporting any failure (including a failed restore) as an error string.