pub struct Storage { /* private fields */ }Expand description
Browser storage interface.
This provides a typed interface to browser storage APIs. In WASM, this uses actual localStorage/sessionStorage. In tests/non-WASM, this uses an in-memory fallback.
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn new(storage_type: StorageType) -> Self
pub fn new(storage_type: StorageType) -> Self
Create a new storage instance.
Sourcepub const fn storage_type(&self) -> StorageType
pub const fn storage_type(&self) -> StorageType
Get the storage type.
Sourcepub fn clear(&self) -> Result<(), StorageError>
pub fn clear(&self) -> Result<(), StorageError>
Clear all values in storage.
Sourcepub fn get_json<T: DeserializeOwned>(
&self,
key: &str,
) -> Result<Option<T>, StorageError>
pub fn get_json<T: DeserializeOwned>( &self, key: &str, ) -> Result<Option<T>, StorageError>
Get a value and deserialize it as JSON.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl UnwindSafe for Storage
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
Mutably borrows from an owned value. Read more