Trait ioat::WriteAt
[−]
[src]
pub trait WriteAt { fn write_at(&mut self, pos: u64, buf: &[u8]) -> Result<usize>; fn flush(&mut self) -> Result<()>; fn write_all_at(&mut self, pos: u64, buf: &[u8]) -> Result<()> { ... } }
The WriteAt
trait allows for atomically writing bytes to a sink at specific offsets.
As an example, this trait is implemented by File
. Similarly to
ReadAt
it is not implemented for &File
,
or other Write + Seek
types in general, as this would not be
thread-safe.
If it can be guaranteed, that a Write + Seek
value will not seek
in parallel to a call to write_at
, it can be wrapped in
AssertThreadSafe
to implement this
trait.
Required Methods
fn write_at(&mut self, pos: u64, buf: &[u8]) -> Result<usize>
Writes some bytes at pos
bytes into self
.
This method returns the number of bytes written. If Ok(n)
is
returned, then it is guaranteed, that 0 <= n <= buf.len()
.
Errors
This method can return any I/O error.
fn flush(&mut self) -> Result<()>
Provided Methods
fn write_all_at(&mut self, pos: u64, buf: &[u8]) -> Result<()>
Writes exactly buf.len()
bytes at pos
bytes into self
.
This is usually handled by repeatedly calling write_at
until
the entire buffer has been written. This method is an analogue
to write_all
for Write
.
Errors
If write_at
returns an error, then this method immediately
propagates it by returning.
If write_at
returns Ok(0)
, indicating that no more bytes
could be written, then this method returns an error of kind
WriteZero
.