pub trait ByteSource {
// Required methods
fn read_range(
&self,
offset: u64,
length: u64,
) -> impl Future<Output = Result<Vec<u8>, CopcError>>;
fn size(&self) -> impl Future<Output = Result<Option<u64>, CopcError>>;
// Provided method
fn read_ranges(
&self,
ranges: &[(u64, u64)],
) -> impl Future<Output = Result<Vec<Vec<u8>>, CopcError>> { ... }
}Expand description
Async random-access byte source.
Implementations can back this with HTTP range requests, local file I/O, in-memory buffers, or any other random-access mechanism.
All methods return non-Send futures for WASM compatibility.
Required Methods§
Provided Methods§
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 ByteSource for &[u8]
Byte source over a shared slice reference.
impl ByteSource for &[u8]
Byte source over a shared slice reference.
Source§impl ByteSource for Vec<u8>
In-memory byte source, useful for testing and when data is already loaded.
impl ByteSource for Vec<u8>
In-memory byte source, useful for testing and when data is already loaded.