pub struct AsyncReader { /* private fields */ }
Expand description
Wraps a fidl_fuchsia_io::FileProxy
and implements futures::io::AsyncRead
, which allows one
to perform asynchronous file reads that don’t block the current thread while waiting for data.
Implementations§
Source§impl AsyncReader
impl AsyncReader
Sourcepub fn from_proxy(file: FileProxy) -> Result<Self, AsyncReaderError>
pub fn from_proxy(file: FileProxy) -> Result<Self, AsyncReaderError>
Errors if the provided FileProxy
does not exclusively own the wrapped channel.
Exclusive ownership avoids surprising behavior arising from the mismatch between the
semantics for AsyncRead
and fuchsia.io/File.Read
. On e.g. Linux, if two AsyncRead
objects were wrapping the same file descriptor and a call to poll_read
on one of the
AsyncRead
objects returned Pending
, a client would generally not expect the offset of
the underlying file descriptor to advance. Meaning that a client could then call poll_read
on the other AsyncRead
object and expect not to miss any file contents. However, with an
AsyncRead
implementation that wraps fuchsia.io/File.Read
, a poll_read
call that
returns Pending
would advance the file offset, meaning that interleaving usage of
AsyncRead
objects that share a channel would return file contents in surprising order.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncReader
impl !RefUnwindSafe for AsyncReader
impl Send for AsyncReader
impl Sync for AsyncReader
impl Unpin for AsyncReader
impl !UnwindSafe for AsyncReader
Blanket Implementations§
§impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
§fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
buf
in asynchronous
manner, returning a future type. Read more§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
AsyncRead
into bufs
using vectored
IO operations. Read more§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf
,
returning an error if end of file (EOF) is hit sooner. Read more§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
AsyncRead
. Read more§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
AsyncRead
. Read more