Skip to main content

AsyncReadSource

Struct AsyncReadSource 

Source
pub struct AsyncReadSource<R> { /* private fields */ }
Expand description

A sequential AsyncSource over any AsyncRead (an HTTP body, a socket). Reads ahead of the stream position skip forward; reads behind it fail with SourceError::BeyondWindow, and the length is known only once the stream has ended.

Implementations§

Source§

impl<R> AsyncReadSource<R>

Source

pub fn new(reader: R) -> Self

Wrap reader, positioned at offset 0.

Trait Implementations§

Source§

impl<R: AsyncRead + Unpin + Send> AsyncSource for AsyncReadSource<R>

Source§

async fn read_at( &mut self, offset: u64, out: &mut [u8], ) -> Result<usize, BoxedError>

Read up to out.len() bytes at offset into out and return the count. Like AsyncRead, a read may return fewer bytes than asked: whatever has arrived, so a decoder can start on it. Zero means the source ends at offset.
Source§

fn len_hint(&self) -> Option<u64>

Total length if known without reading ahead.
Source§

async fn len(&mut self) -> Result<u64, BoxedError>

Total length. Sequential sources can only answer once they reached the end; they return an error before that.
Source§

fn read_ranges( &mut self, reqs: &mut [(u64, &mut [u8])], ) -> impl Future<Output = Result<(), BoxedError>> + Send

Fill each buffer from its offset. Sources that can serve ranges concurrently (HTTP/2, object stores) override this to overlap them; the default reads them one after another.
Source§

impl<R: Debug> Debug for AsyncReadSource<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for AsyncReadSource<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for AsyncReadSource<R>
where R: RefUnwindSafe,

§

impl<R> Send for AsyncReadSource<R>
where R: Send,

§

impl<R> Sync for AsyncReadSource<R>
where R: Sync,

§

impl<R> Unpin for AsyncReadSource<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for AsyncReadSource<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for AsyncReadSource<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.