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>
impl<R> AsyncReadSource<R>
Trait Implementations§
Source§impl<R: AsyncRead + Unpin + Send> AsyncSource for AsyncReadSource<R>
impl<R: AsyncRead + Unpin + Send> AsyncSource for AsyncReadSource<R>
Source§async fn read_at(
&mut self,
offset: u64,
out: &mut [u8],
) -> Result<usize, BoxedError>
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§async fn len(&mut self) -> Result<u64, BoxedError>
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
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more