pub trait ContentStore:
Send
+ Sync
+ 'static {
// Required methods
fn get(
&self,
interest: &Interest,
) -> impl Future<Output = Option<CsEntry>> + Send;
fn insert(
&self,
data: Bytes,
name: Arc<Name>,
meta: CsMeta,
) -> impl Future<Output = InsertResult> + Send;
fn evict(&self, name: &Name) -> impl Future<Output = bool> + Send;
fn capacity(&self) -> CsCapacity;
// Provided methods
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
fn current_bytes(&self) -> usize { ... }
fn set_capacity(&self, _max_bytes: usize) { ... }
fn variant_name(&self) -> &str { ... }
fn evict_prefix(
&self,
_prefix: &Name,
_limit: Option<usize>,
) -> impl Future<Output = usize> + Send { ... }
fn stats(&self) -> CsStats { ... }
}Expand description
The ContentStore trait.
All methods are async to allow persistent (disk-backed) implementations.
In-memory implementations complete synchronously but Tokio will inline the
no-op future at zero cost.
Required Methods§
Sourcefn get(
&self,
interest: &Interest,
) -> impl Future<Output = Option<CsEntry>> + Send
fn get( &self, interest: &Interest, ) -> impl Future<Output = Option<CsEntry>> + Send
Look up a Data packet matching interest.
Honours MustBeFresh and CanBePrefix selectors.
Sourcefn insert(
&self,
data: Bytes,
name: Arc<Name>,
meta: CsMeta,
) -> impl Future<Output = InsertResult> + Send
fn insert( &self, data: Bytes, name: Arc<Name>, meta: CsMeta, ) -> impl Future<Output = InsertResult> + Send
Store a Data packet. May evict least-recently-used entries to make room.
Sourcefn evict(&self, name: &Name) -> impl Future<Output = bool> + Send
fn evict(&self, name: &Name) -> impl Future<Output = bool> + Send
Explicitly evict the entry for name.
Sourcefn capacity(&self) -> CsCapacity
fn capacity(&self) -> CsCapacity
Current capacity configuration.
Provided Methods§
Sourcefn current_bytes(&self) -> usize
fn current_bytes(&self) -> usize
Total bytes currently used.
Sourcefn set_capacity(&self, _max_bytes: usize)
fn set_capacity(&self, _max_bytes: usize)
Update the maximum byte capacity at runtime.
Sourcefn variant_name(&self) -> &str
fn variant_name(&self) -> &str
Human-readable name of this CS implementation (e.g. “lru”, “sharded-lru”).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.