pub trait FileIo: Send + Sync {
// Required methods
fn read_at(
&self,
offset: u64,
buffer: &mut [u8],
) -> impl Future<Output = Result<u64, Status>> + Send;
fn write_at(
&self,
offset: u64,
content: &[u8],
) -> impl Future<Output = Result<u64, Status>> + Send;
fn append(
&self,
content: &[u8],
) -> impl Future<Output = Result<(u64, u64), Status>> + Send;
}
Required Methods§
Sourcefn read_at(
&self,
offset: u64,
buffer: &mut [u8],
) -> impl Future<Output = Result<u64, Status>> + Send
fn read_at( &self, offset: u64, buffer: &mut [u8], ) -> impl Future<Output = Result<u64, Status>> + Send
Read at most |buffer.len()| bytes starting at |offset| into |buffer|. The function may read less than |count| bytes and still return success, in which case read_at returns the number of bytes read into |buffer|.
Sourcefn write_at(
&self,
offset: u64,
content: &[u8],
) -> impl Future<Output = Result<u64, Status>> + Send
fn write_at( &self, offset: u64, content: &[u8], ) -> impl Future<Output = Result<u64, Status>> + Send
Write |content| starting at |offset|, returning the number of bytes that were successfully written.
If there are pending attributes to update (see update_attributes
), they should also be
flushed at this time. Otherwise, no attributes should be updated, other than size as needed.
Sourcefn append(
&self,
content: &[u8],
) -> impl Future<Output = Result<(u64, u64), Status>> + Send
fn append( &self, content: &[u8], ) -> impl Future<Output = Result<(u64, u64), Status>> + Send
Appends |content| returning, if successful, the number of bytes written, and the file offset after writing. Implementations should make the writes atomic, so in the event that multiple requests to append are in-flight, it should appear that the two writes are applied in sequence.
If there are pending attributes to update (see update_attributes
), they should also be
flushed at this time. Otherwise, no attributes should be updated, other than size as needed.
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.