pub trait StateStore: Send + Sync {
// Required methods
fn store(&mut self, content: &str) -> StateRef;
fn load(&self, state_ref: &StateRef) -> Option<String>;
fn len(&self) -> usize;
// Provided methods
fn exists(&self, state_ref: &StateRef) -> bool { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
Trait for content-addressed state storage.
Implementations must guarantee:
store(content)returns the sameStateReffor identical contentload(ref)returnsSome(content)if previously stored- Content is immutable once stored
Required Methods§
Sourcefn store(&mut self, content: &str) -> StateRef
fn store(&mut self, content: &str) -> StateRef
Store content and return its reference.
If the content already exists, returns the existing reference without storing again (deduplication).
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".