pub trait PieceGetter: Debug {
// Required methods
fn get_piece<'life0, 'async_trait>(
&'life0 self,
piece_index: PieceIndex,
) -> Pin<Box<dyn Future<Output = Result<Option<Piece>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_pieces<'a, 'async_trait>(
&'a self,
piece_indices: Vec<PieceIndex>,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = (PieceIndex, Result<Option<Piece>>)> + Send + Unpin + 'a>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait;
// Provided method
fn with_fallback<U>(self, other: U) -> FallbackPieceGetter<Self, U>
where Self: Send + Sync + Sized,
U: PieceGetter + Send + Sync { ... }
}Expand description
Trait representing a way to get pieces
Required Methods§
Sourcefn get_piece<'life0, 'async_trait>(
&'life0 self,
piece_index: PieceIndex,
) -> Pin<Box<dyn Future<Output = Result<Option<Piece>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_piece<'life0, 'async_trait>(
&'life0 self,
piece_index: PieceIndex,
) -> Pin<Box<dyn Future<Output = Result<Option<Piece>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get piece by index.
Returns Ok(None) if the piece is not found.
Returns Err(_) if trying to get the piece caused an error.
Sourcefn get_pieces<'a, 'async_trait>(
&'a self,
piece_indices: Vec<PieceIndex>,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = (PieceIndex, Result<Option<Piece>>)> + Send + Unpin + 'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
fn get_pieces<'a, 'async_trait>(
&'a self,
piece_indices: Vec<PieceIndex>,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = (PieceIndex, Result<Option<Piece>>)> + Send + Unpin + 'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
Get pieces with provided indices.
The number of elements in the returned stream is the same as the number of unique
piece_indices.
Provided Methods§
Sourcefn with_fallback<U>(self, other: U) -> FallbackPieceGetter<Self, U>
fn with_fallback<U>(self, other: U) -> FallbackPieceGetter<Self, U>
Returns a piece getter that falls back to other if self does not return the piece.
Piece getters may need to be wrapped in Arc to be used with this method.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".