Struct fuchsia_fs::file::AsyncFile
source · pub struct AsyncFile { /* private fields */ }
Expand description
Wraps a fidl_fuchsia_io::FileProxy
and implements AsyncReadAt
and AsyncGetSize
, which
allows one to perform asynchronous file reads that don’t block the current thread while waiting
for data.
Unlike AsyncReader
, this struct does not require exclusive ownership, because read_at
does
not rely on the file offset state in the connection. This is useful if one wants to efficiently
read different parts of the file at the same time.
Implementations§
Trait Implementations§
source§impl AsyncGetSize for AsyncFile
impl AsyncGetSize for AsyncFile
source§impl AsyncReadAt for AsyncFile
impl AsyncReadAt for AsyncFile
source§fn poll_read_at(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
offset: u64,
buf: &mut [u8],
) -> Poll<Result<usize>>
fn poll_read_at( self: Pin<&mut Self>, cx: &mut Context<'_>, offset: u64, buf: &mut [u8], ) -> Poll<Result<usize>>
Attempt to read at most
buf.len()
bytes starting at offset
into buf
. On success
returns the number of bytes read.
Contents of buf
are only altered on success.
Reads of more than zero but fewer than buf.len()
bytes do NOT indicate EOF.
Reads of zero bytes only occur if buf.len() == 0
or EOF.Auto Trait Implementations§
impl Freeze for AsyncFile
impl !RefUnwindSafe for AsyncFile
impl Send for AsyncFile
impl Sync for AsyncFile
impl Unpin for AsyncFile
impl !UnwindSafe for AsyncFile
Blanket Implementations§
source§impl<T> AsyncGetSizeExt for Twhere
T: AsyncGetSize + ?Sized,
impl<T> AsyncGetSizeExt for Twhere
T: AsyncGetSize + ?Sized,
source§impl<T> AsyncReadAtExt for Twhere
T: AsyncReadAt + ?Sized,
impl<T> AsyncReadAtExt for Twhere
T: AsyncReadAt + ?Sized,
source§fn read_at<'a>(&'a mut self, offset: u64, buf: &'a mut [u8]) -> ReadAt<'a, Self>where
Self: Unpin,
fn read_at<'a>(&'a mut self, offset: u64, buf: &'a mut [u8]) -> ReadAt<'a, Self>where
Self: Unpin,
Returns a future that reads at
offset
, and fill buf
, on success the number of bytes
read is returned.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
Mutably borrows from an owned value. Read more