pub trait Storage: Debug {
// Required methods
fn read(&self, key: &str) -> Result<Option<String>, StorageError>;
fn write(&mut self, key: &str, value: &str) -> Result<(), StorageError>;
fn delete(&mut self, key: &str) -> Result<(), StorageError>;
fn list(&self) -> Result<Vec<String>, StorageError>;
}Expand description
A place to persist small named blobs of text (RON documents, typically):
files on native, localStorage on web.
Keys must match ^[a-z0-9_-]{1,64}$ (is_valid_key); implementations
turn a key straight into a file name, so anything else is rejected rather
than sanitised.
Required Methods§
Sourcefn read(&self, key: &str) -> Result<Option<String>, StorageError>
fn read(&self, key: &str) -> Result<Option<String>, StorageError>
The value stored at key, or None if nothing has been written
there (or it was deleted).
Sourcefn write(&mut self, key: &str, value: &str) -> Result<(), StorageError>
fn write(&mut self, key: &str, value: &str) -> Result<(), StorageError>
Stores value at key, replacing whatever was there.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".