pub struct StorageIndexBuilder {
pub entries: HashMap<String, IndexEntry>,
}Expand description
Builds and maintains a secondary index over block metadata.
§Example
use ipfrs_storage::index_builder::{
IndexEntry, QueryFilter, StorageIndexBuilder,
};
let mut idx = StorageIndexBuilder::new();
idx.insert(IndexEntry {
cid: "QmA".into(),
size_bytes: 1024,
created_at_secs: 1_000,
tags: vec!["audio".into()],
content_type: "audio/mpeg".into(),
});
let results = idx.query(&QueryFilter::HasTag { tag: "audio".into() });
assert_eq!(results.len(), 1);Fields§
§entries: HashMap<String, IndexEntry>Primary storage: CID → IndexEntry.
Implementations§
Source§impl StorageIndexBuilder
impl StorageIndexBuilder
Sourcepub fn insert(&mut self, entry: IndexEntry)
pub fn insert(&mut self, entry: IndexEntry)
Inserts (or replaces) an entry keyed by its CID.
Sourcepub fn remove(&mut self, cid: &str) -> bool
pub fn remove(&mut self, cid: &str) -> bool
Removes the entry with the given CID.
Returns true if an entry was present and removed, false otherwise.
Sourcepub fn query(&self, filter: &QueryFilter) -> Vec<&IndexEntry>
pub fn query(&self, filter: &QueryFilter) -> Vec<&IndexEntry>
Returns all entries that satisfy filter, sorted by
created_at_secs ascending.
Replaces the tag list for the entry identified by cid.
Returns true if the entry was found and updated, false otherwise.
Sourcepub fn stats(&self) -> IndexStats
pub fn stats(&self) -> IndexStats
Returns summary statistics for the current index state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StorageIndexBuilder
impl RefUnwindSafe for StorageIndexBuilder
impl Send for StorageIndexBuilder
impl Sync for StorageIndexBuilder
impl Unpin for StorageIndexBuilder
impl UnsafeUnpin for StorageIndexBuilder
impl UnwindSafe for StorageIndexBuilder
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more