pub trait ByteSource: Debug {
// Required methods
fn len(&self) -> u64;
fn read_at(
&self,
offset: u64,
target: &mut [u8],
) -> Result<(), BackendError>;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn as_contiguous(&self) -> Option<&[u8]> { ... }
}Expand description
A bounded byte source that may be physically segmented.
Transport adapters can implement this trait over validated descriptor-backed regions so
providers can read directly into final program or buffer storage without first coalescing the
complete payload. Every range fully contained in 0..len() must be readable for the duration of
the backend call. The optional contiguous view preserves the single-slice fast path.
Required Methods§
Provided Methods§
fn is_empty(&self) -> bool
Sourcefn as_contiguous(&self) -> Option<&[u8]>
fn as_contiguous(&self) -> Option<&[u8]>
Borrow the complete logical source when it is one contiguous region.
A returned slice has length Self::len and contains the same bytes as read_at.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".