Trait components::engine::d2::subsystem::StorageSystem
source · [−]pub trait StorageSystem {
fn is_supported(&self) -> bool;
fn set<A>(&self, key: String, value: A) -> bool
where
A: StorageItem;
fn get<A>(&self, key: String) -> Option<&A>
where
A: StorageItem;
fn remove(&mut self, key: String);
fn clear(&mut self);
}
Expand description
A simple key/value store that persists between sessions.
Required Methods
fn is_supported(&self) -> bool
fn is_supported(&self) -> bool
True if the environment supports persisted storage. Otherwise, the storage is backed by a Map and not actually persisted between sessions.
fn set<A>(&self, key: String, value: A) -> bool where
A: StorageItem,
fn set<A>(&self, key: String, value: A) -> bool where
A: StorageItem,
Add a key to the storage, replacing any existing value. @param value An object that can be serialized with Serializer. @returns True if the value was successfully serialized and persisted.
Retrieve a value from storage for a given key.