common_base::range_read

Trait RangeReader

source
pub trait RangeReader:
    Sync
    + Send
    + Unpin {
    // Required methods
    fn metadata<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn read<'life0, 'async_trait>(
        &'life0 self,
        range: Range<u64>,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn read_into<'life0, 'life1, 'async_trait>(
        &'life0 self,
        range: Range<u64>,
        buf: &'life1 mut (impl 'async_trait + BufMut + Send),
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn read_vec<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ranges: &'life1 [Range<u64>],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

RangeReader reads a range of bytes from a source.

Required Methods§

source

fn metadata<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the metadata of the source.

source

fn read<'life0, 'async_trait>( &'life0 self, range: Range<u64>, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reads the bytes in the given range.

Provided Methods§

source

fn read_into<'life0, 'life1, 'async_trait>( &'life0 self, range: Range<u64>, buf: &'life1 mut (impl 'async_trait + BufMut + Send), ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads the bytes in the given range into the buffer.

Handles the buffer based on its capacity:

  • If the buffer is insufficient to hold the bytes, it will either:
    • Allocate additional space (e.g., for Vec<u8>)
    • Panic (e.g., for &mut [u8])
source

fn read_vec<'life0, 'life1, 'async_trait>( &'life0 self, ranges: &'life1 [Range<u64>], ) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads the bytes in the given ranges.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

source§

impl RangeReader for Vec<u8>

source§

fn metadata<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn read<'life0, 'async_trait>( &'life0 self, range: Range<u64>, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<R: ?Sized + RangeReader> RangeReader for &R

source§

fn metadata<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn read<'life0, 'async_trait>( &'life0 self, range: Range<u64>, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn read_into<'life0, 'life1, 'async_trait>( &'life0 self, range: Range<u64>, buf: &'life1 mut (impl 'async_trait + BufMut + Send), ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn read_vec<'life0, 'life1, 'async_trait>( &'life0 self, ranges: &'life1 [Range<u64>], ) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§