pub trait File: Sized {
// Required methods
fn read_all(
&mut self,
) -> impl Future<Output = Result<Vec<u8>, FileSystemError>>;
fn read_segment(
&mut self,
offset: Offset,
dest: &mut [u8],
) -> impl Future<Output = Result<usize, FileSystemError>>;
}Expand description
A trait for reading files
A simple (non-async) implementation would hold a std::fs::File handle.
Required Methods§
Sourcefn read_all(&mut self) -> impl Future<Output = Result<Vec<u8>, FileSystemError>>
fn read_all(&mut self) -> impl Future<Output = Result<Vec<u8>, FileSystemError>>
Read everything in the file
This should be idempotent with any other reads. If the platform requires it, implementors should seek to the start of the file before reading.
Sourcefn read_segment(
&mut self,
offset: Offset,
dest: &mut [u8],
) -> impl Future<Output = Result<usize, FileSystemError>>
fn read_segment( &mut self, offset: Offset, dest: &mut [u8], ) -> impl Future<Output = Result<usize, FileSystemError>>
Read a segment of the file into the destination buffer. If less data is
available than the size of the buffer, then only the first n bytes of
the buffer are modified. Therefore implementors should take care not to
error on EOF conditions.
Successful reads return the number of bytes read.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.