pub trait AsyncSource: Send {
// Required methods
fn read_at(
&mut self,
offset: u64,
out: &mut [u8],
) -> impl Future<Output = Result<usize, BoxedError>> + Send;
fn len(&mut self) -> impl Future<Output = Result<u64, BoxedError>> + Send;
// Provided methods
fn read_ranges(
&mut self,
reqs: &mut [(u64, &mut [u8])],
) -> impl Future<Output = Result<(), BoxedError>> + Send { ... }
fn len_hint(&self) -> Option<u64> { ... }
}Expand description
Where the async drivers get bytes: a socket, an HTTP body, an object store with range requests.
Required Methods§
Sourcefn read_at(
&mut self,
offset: u64,
out: &mut [u8],
) -> impl Future<Output = Result<usize, BoxedError>> + Send
fn read_at( &mut self, offset: u64, out: &mut [u8], ) -> impl Future<Output = Result<usize, BoxedError>> + Send
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.
Provided Methods§
Sourcefn 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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".