pub trait WriteAt {
// Required method
fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize>;
// Provided methods
fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()> { ... }
fn write_vectored_at(
&self,
bufs: &[IoSlice<'_>],
offset: u64
) -> Result<usize> { ... }
fn flush(&self) -> Result<()> { ... }
}
Expand description
The WriteAt
trait allows for writing bytes to a source at a given offset.
Additionally, the methods of this trait only require a shared reference, which makes it ideal for parallel use.
Required Methods§
Provided Methods§
sourcefn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()>
fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()>
Attempts to write an entire buffer starting from a given offset.
§Errors
This function will return the first error of
non-io::ErrorKind::Interrupted
kind that write_at
returns.
sourcefn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> Result<usize>
fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> Result<usize>
Like write_at
, except that it writes from a slice of buffers.
Data is copied from each buffer in order, with the final buffer read
from possibly being only partially consumed. This method must behave as
a call to write_at
with the buffers concatenated would.