pub struct FarmerCaches { /* private fields */ }Expand description
Collection of FarmerCache instances for load balancing
Implementations§
Source§impl FarmerCaches
impl FarmerCaches
Sourcepub async fn get_piece<Key>(&self, key: Key) -> Option<Piece>where
RecordKey: From<Key>,
pub async fn get_piece<Key>(&self, key: Key) -> Option<Piece>where
RecordKey: From<Key>,
Get piece from cache
Sourcepub async fn get_pieces<'a, PieceIndices>(
&'a self,
piece_indices: PieceIndices,
) -> impl Stream<Item = (PieceIndex, Option<Piece>)> + Send + Unpin + 'a
pub async fn get_pieces<'a, PieceIndices>( &'a self, piece_indices: PieceIndices, ) -> impl Stream<Item = (PieceIndex, Option<Piece>)> + Send + Unpin + 'a
Get pieces from cache.
Number of elements in returned stream is the same as number of unique piece_indices.
Sourcepub async fn has_pieces(
&self,
piece_indices: Vec<PieceIndex>,
) -> Vec<PieceIndex>
pub async fn has_pieces( &self, piece_indices: Vec<PieceIndex>, ) -> Vec<PieceIndex>
Returns a filtered list of pieces that were found in farmer cache, order is not guaranteed
Sourcepub async fn maybe_store_additional_piece(
&self,
piece_index: PieceIndex,
piece: &Piece,
) -> bool
pub async fn maybe_store_additional_piece( &self, piece_index: PieceIndex, piece: &Piece, ) -> bool
Try to store a piece in additional downloaded pieces, if there is space for it.
Returns true if the piece was added to one or more caches, and false if it was already
stored, or there was no space.
Trait Implementations§
Source§impl Clone for FarmerCaches
impl Clone for FarmerCaches
Source§fn clone(&self) -> FarmerCaches
fn clone(&self) -> FarmerCaches
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FarmerCaches
impl Debug for FarmerCaches
Source§impl From<Arc<[FarmerCache]>> for FarmerCaches
impl From<Arc<[FarmerCache]>> for FarmerCaches
Source§fn from(caches: Arc<[FarmerCache]>) -> Self
fn from(caches: Arc<[FarmerCache]>) -> Self
Converts to this type from the input type.
Source§impl From<FarmerCache> for FarmerCaches
impl From<FarmerCache> for FarmerCaches
Source§fn from(cache: FarmerCache) -> Self
fn from(cache: FarmerCache) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for FarmerCaches
impl !RefUnwindSafe for FarmerCaches
impl Send for FarmerCaches
impl Sync for FarmerCaches
impl Unpin for FarmerCaches
impl !UnwindSafe for FarmerCaches
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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