pub trait RawFileIoConnection: Send + Sync {
// Required methods
fn read(
&self,
count: u64,
) -> impl Future<Output = Result<Vec<u8>, Status>> + Send;
fn read_at(
&self,
offset: u64,
count: u64,
) -> impl Future<Output = Result<Vec<u8>, Status>> + Send;
fn write(
&self,
data: &[u8],
) -> impl Future<Output = Result<u64, Status>> + Send;
fn write_at(
&self,
offset: u64,
data: &[u8],
) -> impl Future<Output = Result<u64, Status>> + Send;
fn seek(
&self,
offset: i64,
origin: SeekOrigin,
) -> impl Future<Output = Result<u64, Status>> + Send;
fn update_flags(&self, flags: OpenFlags) -> Status;
}
Expand description
Trait for dispatching read, write, and seek FIDL requests for a given connection. The implementer of this trait is responsible for maintaining the per connection state.
Files that support Streams should handle reads and writes via a Pager instead of implementing this trait.
Required Methods§
Sourcefn read(
&self,
count: u64,
) -> impl Future<Output = Result<Vec<u8>, Status>> + Send
fn read( &self, count: u64, ) -> impl Future<Output = Result<Vec<u8>, Status>> + Send
Reads at most count
bytes from the file starting at the connection’s seek offset and
advances the seek offset.
Sourcefn read_at(
&self,
offset: u64,
count: u64,
) -> impl Future<Output = Result<Vec<u8>, Status>> + Send
fn read_at( &self, offset: u64, count: u64, ) -> impl Future<Output = Result<Vec<u8>, Status>> + Send
Reads count
bytes from the file starting at offset
.
Sourcefn write(&self, data: &[u8]) -> impl Future<Output = Result<u64, Status>> + Send
fn write(&self, data: &[u8]) -> impl Future<Output = Result<u64, Status>> + Send
Writes data
to the file starting at the connect’s seek offset and advances the seek
offset. If the connection is in append mode then the seek offset is moved to the end of the
file before writing. Returns the number of bytes written.
Sourcefn write_at(
&self,
offset: u64,
data: &[u8],
) -> impl Future<Output = Result<u64, Status>> + Send
fn write_at( &self, offset: u64, data: &[u8], ) -> impl Future<Output = Result<u64, Status>> + Send
Writes data
to the file starting at offset
. Returns the number of bytes written.
Sourcefn seek(
&self,
offset: i64,
origin: SeekOrigin,
) -> impl Future<Output = Result<u64, Status>> + Send
fn seek( &self, offset: i64, origin: SeekOrigin, ) -> impl Future<Output = Result<u64, Status>> + Send
Modifies the connection’s seek offset. Returns the connections new seek offset.
Sourcefn update_flags(&self, flags: OpenFlags) -> Status
fn update_flags(&self, flags: OpenFlags) -> Status
Notifies the IoOpHandler
that the flags of the connection have changed.
TODO(https://fxbug.dev/376509077): Migrate this to fio::Flags.
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.