pub trait Bundle:
Send
+ Sync
+ Debug {
// Required methods
fn get(&self, namespace: &str, key: &[u8]) -> Option<Bytes>;
fn scan(&self, namespace: &str, visit: &mut dyn FnMut(&[u8], &[u8]));
fn namespaces(&self) -> Vec<String>;
fn describe(&self) -> String;
}Expand description
A read-only set of pre-computed cache entries shipped with an application.
Lookups use the same two coordinates as the local cache: the namespace the
persistence layer computes (<name>/<version>/<segments>) and the
serialized key bytes. A bundle therefore needs no path rewriting, and
several bundles in different formats can be installed side by side.
A bundle is an import format, not a runtime one: import
copies its entries into the local storage once, and nothing consults it
afterwards. Runtime lookups only ever touch
Storage.
Reads hand back Bytes, which a format can serve as a zero-copy window
into its own storage: an embedded bundle returns a view of its blob rather
than a copy.
All methods degrade silently: a miss on any failure.
Required Methods§
Sourcefn get(&self, namespace: &str, key: &[u8]) -> Option<Bytes>
fn get(&self, namespace: &str, key: &[u8]) -> Option<Bytes>
The value stored under key in namespace.
Sourcefn scan(&self, namespace: &str, visit: &mut dyn FnMut(&[u8], &[u8]))
fn scan(&self, namespace: &str, visit: &mut dyn FnMut(&[u8], &[u8]))
Visits every entry of namespace.
Sourcefn namespaces(&self) -> Vec<String>
fn namespaces(&self) -> Vec<String>
Every namespace the bundle holds entries for.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".