pub trait File {
// Required methods
fn size(&self) -> FileSizeFuture;
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> FileReadFuture<'a>;
fn read_at<'a>(
&'a self,
offset: u64,
buf: &'a mut [u8],
) -> FileReadFuture<'a>;
fn write<'a>(&'a mut self, bytes: &'a [u8]) -> FileWriteFuture<'a>;
fn write_at<'a>(
&'a mut self,
offset: u64,
bytes: &'a [u8],
) -> FileWriteFuture<'a>;
fn set_len(&mut self, len: u64) -> FileWriteFuture<'_>;
fn flush(&mut self) -> FileWriteFuture<'_>;
}Expand description
A file opened through Files::open, read and written at an offset and streamed.
The cursor methods advance where the file reads and writes next; the offset methods leave it alone. A platform whose file system has no cursor of its own keeps one here.
Required Methods§
Sourcefn size(&self) -> FileSizeFuture
fn size(&self) -> FileSizeFuture
The file’s length in bytes.
Sourcefn read<'a>(&'a mut self, buf: &'a mut [u8]) -> FileReadFuture<'a>
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> FileReadFuture<'a>
Reads into buf from the cursor, advancing it by what it read; answers how many bytes,
0 at the end.
Sourcefn read_at<'a>(&'a self, offset: u64, buf: &'a mut [u8]) -> FileReadFuture<'a>
fn read_at<'a>(&'a self, offset: u64, buf: &'a mut [u8]) -> FileReadFuture<'a>
Reads into buf from offset, leaving the cursor alone.
Sourcefn write<'a>(&'a mut self, bytes: &'a [u8]) -> FileWriteFuture<'a>
fn write<'a>(&'a mut self, bytes: &'a [u8]) -> FileWriteFuture<'a>
Writes bytes at the cursor, advancing it by their length.
Sourcefn write_at<'a>(
&'a mut self,
offset: u64,
bytes: &'a [u8],
) -> FileWriteFuture<'a>
fn write_at<'a>( &'a mut self, offset: u64, bytes: &'a [u8], ) -> FileWriteFuture<'a>
Writes bytes at offset, leaving the cursor alone.
Sourcefn set_len(&mut self, len: u64) -> FileWriteFuture<'_>
fn set_len(&mut self, len: u64) -> FileWriteFuture<'_>
Cuts the file short at len, or fills it with zeroes to that length.
Sourcefn flush(&mut self) -> FileWriteFuture<'_>
fn flush(&mut self) -> FileWriteFuture<'_>
Hands what was written to the system, so that it survives the process that wrote it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".