pub struct StreamingAssetReader<R> { /* private fields */ }Expand description
A BundledAssetReader over any byte stream.
Every backend that streams an asset ends at the same loop: fill a chunk, stop at the end, name the asset rather than its resolved location when the read fails. What differs is only what was opened — a file beside the executable, a file in an application bundle, a span of an Android package, or bytes already in hand — and whether the asset ends where its stream does. The loop lives here once; a backend supplies the stream and, when its asset is a span of something larger, how many bytes of it are its own.
Implementations§
Source§impl<R: Read + Send> StreamingAssetReader<R>
impl<R: Read + Send> StreamingAssetReader<R>
Sourcepub fn new(path: impl Into<String>, source: R) -> Self
pub fn new(path: impl Into<String>, source: R) -> Self
A reader over a stream whose end is the asset’s end.
Sourcepub fn with_length(path: impl Into<String>, source: R, len: u64) -> Self
pub fn with_length(path: impl Into<String>, source: R, len: u64) -> Self
A reader over len bytes of a stream that continues past the asset —
an Android package’s file descriptor addresses the whole package, so
the asset’s end is a count rather than end of file.
Trait Implementations§
Source§impl<R: Read + Send> BundledAssetReader for StreamingAssetReader<R>
impl<R: Read + Send> BundledAssetReader for StreamingAssetReader<R>
Source§fn read_chunk(&mut self) -> Result<Option<Vec<u8>>, BundledAssetError>
fn read_chunk(&mut self) -> Result<Option<Vec<u8>>, BundledAssetError>
None at end of asset.