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§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 !RefUnwindSafe for FarmerCaches
impl !UnwindSafe for FarmerCaches
impl Forget for FarmerCaches
impl Freeze for FarmerCaches
impl Move for FarmerCaches
impl Send for FarmerCacheswhere
Arc<[FarmerCache]>: Send,
impl Sync for FarmerCacheswhere
Arc<[FarmerCache]>: Sync,
impl Unpin for FarmerCacheswhere
*const ArcInner<[FarmerCache]> is !null: Unpin,
*const ArcInner<RwLock<PieceCachesState>> is !null: Unpin,
Align8<usize>: Unpin,
Align8<*mut Inner<()>>: Unpin,
*const LeafNode<KeyWithDistance, FarmerCacheOffset> is !null: Unpin,
Box<(KeyWithDistance, FarmerCacheOffset)>: Unpin,
*const u8 is !null: Unpin,
Arc<dyn PieceCache>: Unpin,
*const ArcInner<PlotCaches> is !null: Unpin,
Arc<dyn PlotCache>: Unpin,
*const ArcInner<Handlers> is !null: Unpin,
Arc<Mutex<RawMutex, Inner<Arc<dyn Fn(&f32) + Sync + Send>>>>: Unpin,
BoundedSenderInner<WorkerCommand>: Unpin,
*const ArcInner<FarmerCacheMetrics> is !null: Unpin,
Arc<Atomic<u64>>: Unpin,
Arc<Atomic<i64>>: Unpin,
impl UnsafeUnpin for FarmerCacheswhere
*const ArcInner<[FarmerCache]> is !null: UnsafeUnpin,
PhantomData<[FarmerCache]>: UnsafeUnpin,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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