pub trait Store:
Clone
+ Debug
+ Default
+ Send
+ Sync {
// Required methods
fn get(&self, key: &str) -> Option<&Arc<Entry>>;
fn insert(&self, key: String, value: Arc<Entry>) -> Self;
fn remove(&self, key: &str) -> Self;
fn insert_mut(&mut self, key: String, value: Arc<Entry>);
fn remove_mut(&mut self, key: &str) -> bool;
fn len(&self) -> usize;
fn iter(&self) -> impl Iterator<Item = (&String, &Arc<Entry>)>;
fn range_prefix<'a>(
&'a self,
prefix: &'a str,
) -> impl Iterator<Item = (&'a String, &'a Arc<Entry>)>;
fn shares_allocation_with(&self, other: &Self) -> bool;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A persistent ordered map from key to entry.
Implementations must iterate in ascending key order, because that ordering is what makes commit ids and listings reproducible.
Required Methods§
Sourcefn insert(&self, key: String, value: Arc<Entry>) -> Self
fn insert(&self, key: String, value: Arc<Entry>) -> Self
Return a new map with key set, leaving self untouched.
Sourcefn insert_mut(&mut self, key: String, value: Arc<Entry>)
fn insert_mut(&mut self, key: String, value: Arc<Entry>)
Set key in place. Equivalent to *self = self.insert(..), but skips
copying nodes this map holds exclusively.
Sourcefn remove_mut(&mut self, key: &str) -> bool
fn remove_mut(&mut self, key: &str) -> bool
Remove key in place. Returns whether the key was present.
Sourcefn iter(&self) -> impl Iterator<Item = (&String, &Arc<Entry>)>
fn iter(&self) -> impl Iterator<Item = (&String, &Arc<Entry>)>
All entries, in ascending key order.
Sourcefn range_prefix<'a>(
&'a self,
prefix: &'a str,
) -> impl Iterator<Item = (&'a String, &'a Arc<Entry>)>
fn range_prefix<'a>( &'a self, prefix: &'a str, ) -> impl Iterator<Item = (&'a String, &'a Arc<Entry>)>
All entries whose key starts with prefix, in ascending key order.
Whether two maps are the same allocation, i.e. share all their nodes.
Used by the test that shows forking copies nothing.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".