pub trait Storage {
// Required methods
fn read(&self, name: &str) -> Result<Option<Vec<u8>>, String>;
fn write(&self, name: &str, bytes: &[u8]) -> Result<(), String>;
fn remove(&self, name: &str) -> Result<(), String>;
}Expand description
Named pieces of data kept between runs.
use ravenrs_core::{MemoryStorage, Storage};
let storage = MemoryStorage::default();
storage.write("records", b"{}")?;
assert_eq!(storage.read("records")?, Some(b"{}".to_vec()));
storage.remove("records")?;
assert_eq!(storage.read("records")?, None);Required Methods§
Sourcefn read(&self, name: &str) -> Result<Option<Vec<u8>>, String>
fn read(&self, name: &str) -> Result<Option<Vec<u8>>, String>
What is kept under name, or None if nothing is.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Implementors§
impl Storage for FileStorage
Available on non-WebAssembly only.