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;
}
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
.