pub trait StorageProvider:
Send
+ Sync
+ 'static {
// Required methods
fn get(&self, origin: &OriginKey, key: &str) -> Option<String>;
fn set(
&self,
origin: &OriginKey,
key: &str,
value: &str,
) -> Result<(), StorageError>;
fn remove(&self, origin: &OriginKey, key: &str);
fn clear(&self, origin: &OriginKey);
}Expand description
Per-origin key/value storage, the model behind localStorage.
Synchronous, because the API it backs is. Values are strings, because the API it backs stores strings: a caller with structure serialises it, exactly as it would against a browser, and no implementation here looks inside a value.
Every method takes an OriginKey, and an implementation must scope by
it. This is the whole security contract of the trait and it is not
optional. An implementation that ignores the argument compiles, works in a
single-origin test, and leaks every site’s data to every other.
Required Methods§
fn get(&self, origin: &OriginKey, key: &str) -> Option<String>
fn set( &self, origin: &OriginKey, key: &str, value: &str, ) -> Result<(), StorageError>
fn remove(&self, origin: &OriginKey, key: &str)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".