subspace_data_retrieval::piece_getter

Trait PieceGetter

Source
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§

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl PieceGetter for (PieceIndex, Piece)

Source§

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,

Source§

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,

Source§

impl PieceGetter for NewArchivedSegment

Source§

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,

Source§

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,

Source§

impl<T> PieceGetter for Arc<T>
where T: PieceGetter + Send + Sync + ?Sized,

Source§

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,

Source§

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,

Implementors§