pub struct FileReader { /* private fields */ }Expand description
A streaming reader over a guest-file read response. A background task
pumps chunks into a bounded channel (so a slow consumer applies
backpressure rather than buffering the whole file); FileReader::next
yields the next chunk, None at end of file. Dropping the reader cancels
the download.
Implementations§
Source§impl FileReader
impl FileReader
Sourcepub async fn next(&self) -> Option<Result<Vec<u8>, SailError>>
pub async fn next(&self) -> Option<Result<Vec<u8>, SailError>>
Yield the next file chunk, or None at end of file. A stream error
surfaces as Some(Err(..)).
Sourcepub fn close(&self)
pub fn close(&self)
Abort the background download, cancelling its gRPC stream even when a
next() is stalled awaiting a chunk. Idempotent. A subsequent next()
observes end of stream (None); a next() already awaiting may still
deliver one final buffered chunk before the end.
Sourcepub fn into_stream(self) -> BoxStream<'static, Result<Vec<u8>, SailError>>
pub fn into_stream(self) -> BoxStream<'static, Result<Vec<u8>, SailError>>
Consume the reader into a futures::Stream of chunks, for
StreamExt combinators. For tokio::io::AsyncRead, adapt the stream
with tokio_util::io::StreamReader.
Trait Implementations§
Source§impl Debug for FileReader
impl Debug for FileReader
Source§impl Drop for FileReader
impl Drop for FileReader
Auto Trait Implementations§
impl !Freeze for FileReader
impl !RefUnwindSafe for FileReader
impl Send for FileReader
impl Sync for FileReader
impl Unpin for FileReader
impl UnsafeUnpin for FileReader
impl UnwindSafe for FileReader
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request