pub struct RemoteFragmentIndex { /* private fields */ }Expand description
In-memory index accumulated from received FragmentIndexAnnouncements.
Maps chunk_id → Vec<FragmentPointer>.
Held in crate::control::server::DaemonState under an Arc<RwLock<>>.
Implementations§
Source§impl RemoteFragmentIndex
impl RemoteFragmentIndex
Sourcepub fn upsert(&mut self, ann: FragmentIndexAnnouncement)
pub fn upsert(&mut self, ann: FragmentIndexAnnouncement)
Incorporate a FragmentIndexAnnouncement.
Merges new pointers into the existing list for the chunk, de-duplicating
by fragment_id so repeated announcements are idempotent.
Sourcepub fn pointers_for(&self, chunk_id: &str) -> &[FragmentPointer]
pub fn pointers_for(&self, chunk_id: &str) -> &[FragmentPointer]
All known fragment pointers for a chunk. Returns an empty slice if the chunk has never been announced.
Sourcepub fn pointers_for_peer<'a, 'b>(
&'a self,
chunk_id: &'b str,
peer_id: &'b str,
) -> impl Iterator<Item = &'a FragmentPointer> + use<'a, 'b>
pub fn pointers_for_peer<'a, 'b>( &'a self, chunk_id: &'b str, peer_id: &'b str, ) -> impl Iterator<Item = &'a FragmentPointer> + use<'a, 'b>
Pointers for a chunk hosted by a specific peer.
Sourcepub fn evict_peer(&mut self, peer_id: &str)
pub fn evict_peer(&mut self, peer_id: &str)
Remove all pointer entries for a given peer_id (e.g. after it is
blacklisted or evicted from the network).
Sourcepub fn chunk_count(&self) -> usize
pub fn chunk_count(&self) -> usize
Total number of chunks tracked.
Sourcepub fn pointer_count(&self) -> usize
pub fn pointer_count(&self) -> usize
Total number of fragment pointers across all chunks.
Trait Implementations§
Source§impl Debug for RemoteFragmentIndex
impl Debug for RemoteFragmentIndex
Source§impl Default for RemoteFragmentIndex
impl Default for RemoteFragmentIndex
Source§fn default() -> RemoteFragmentIndex
fn default() -> RemoteFragmentIndex
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RemoteFragmentIndex
impl RefUnwindSafe for RemoteFragmentIndex
impl Send for RemoteFragmentIndex
impl Sync for RemoteFragmentIndex
impl Unpin for RemoteFragmentIndex
impl UnwindSafe for RemoteFragmentIndex
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