pub struct FragmentIndex { /* private fields */ }Expand description
In-memory index: chunk_id → Vec<FragmentMeta>.
Keyed by chunk_id so that the storage manager can quickly find all fragments of a given chunk (for recoding or proof-of-storage responses).
Implementations§
Source§impl FragmentIndex
impl FragmentIndex
Sourcepub fn insert(&mut self, meta: FragmentMeta)
pub fn insert(&mut self, meta: FragmentMeta)
Register a new fragment.
Sourcepub fn remove(
&mut self,
chunk_id: &str,
fragment_id: &str,
) -> Option<FragmentMeta>
pub fn remove( &mut self, chunk_id: &str, fragment_id: &str, ) -> Option<FragmentMeta>
Remove a fragment by chunk_id + fragment_id.
Returns the removed entry if found.
Sourcepub fn fragments_for_chunk(&self, chunk_id: &str) -> &[FragmentMeta]
pub fn fragments_for_chunk(&self, chunk_id: &str) -> &[FragmentMeta]
All fragment records for a given chunk (for recoding / PoS challenges).
Sourcepub fn fragment_count(&self) -> usize
pub fn fragment_count(&self) -> usize
Total number of fragments across all chunks.
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Total bytes occupied by all stored fragments.
Sourcepub fn contains_chunk(&self, chunk_id: &str) -> bool
pub fn contains_chunk(&self, chunk_id: &str) -> bool
Whether the index holds any fragment for the given chunk.
Trait Implementations§
Source§impl Debug for FragmentIndex
impl Debug for FragmentIndex
Source§impl Default for FragmentIndex
impl Default for FragmentIndex
Source§fn default() -> FragmentIndex
fn default() -> FragmentIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FragmentIndex
impl RefUnwindSafe for FragmentIndex
impl Send for FragmentIndex
impl Sync for FragmentIndex
impl Unpin for FragmentIndex
impl UnwindSafe for FragmentIndex
Blanket Implementations§
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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