pub trait WriteAtomic: Write {
// Required methods
fn is_ready_to_write(&self) -> bool;
fn empty_write_buf(&mut self) -> Result<bool>;
// Provided method
fn write_atomic(&mut self, buf: &[u8]) -> Result<(), WriteError> { ... }
}Expand description
The trait guarantees that the data are either written in full - or, in case of an error, none of the data is written. Types implementing the trait must also guarantee that multiple attempts to do the write would not result in data to be written out of the initial ordering.
Required Methods§
Sourcefn is_ready_to_write(&self) -> bool
fn is_ready_to_write(&self) -> bool
Checks whether resource can be written to without blocking.
Sourcefn empty_write_buf(&mut self) -> Result<bool>
fn empty_write_buf(&mut self) -> Result<bool>
Empties any write buffers in a non-blocking way. If a non-blocking
operation is not possible, errors with io::ErrorKind::WouldBlock
kind of io::Error.
§Returns
If the buffer contained any data before this operation.
Provided Methods§
Sourcefn write_atomic(&mut self, buf: &[u8]) -> Result<(), WriteError>
fn write_atomic(&mut self, buf: &[u8]) -> Result<(), WriteError>
Atomic non-blocking I/O write operation, which must either write the whole buffer to a
resource without blocking - or fail with WriteError::NotReady error.
§Safety
Panics on invalid WriteAtomic::write_or_buf implementation, i.e. if it doesn’t handle
EGAGAIN, EINTER, EWOULDBLOCK I/O errors by buffering the data and returns them instead.