Trait ChunkRead

Source
pub trait ChunkRead: Sized {
    type SeekFuture<'f>: Future<Output = Result<()>> + 'f
       where Self: 'f;
    type Future: Future<Output = Result<Option<(Self, BytesMut, usize)>>>;

    // Required methods
    fn seek(&mut self, pos: SeekFrom) -> Self::SeekFuture<'_>;
    fn next(self, buf: BytesMut) -> Self::Future;
}
Expand description

trait for async chunk read from file.

Required Associated Types§

Source

type SeekFuture<'f>: Future<Output = Result<()>> + 'f where Self: 'f

Source

type Future: Future<Output = Result<Option<(Self, BytesMut, usize)>>>

Required Methods§

Source

fn seek(&mut self, pos: SeekFrom) -> Self::SeekFuture<'_>

seek file to skip n bytes with given offset.

Source

fn next(self, buf: BytesMut) -> Self::Future

async read of Self and write into given BytesMut. return Ok(Some(Self, BytesMut, usize)) after successful read where usize is the byte count of data written into buffer. return Ok(None) when self has reached EOF and can not do more read anymore. return Err(io::Error) when read error occur.

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.

Implementors§