[−][src]Trait timeout_io::Writer
A trait for writing with timeouts
Required methods
fn try_write(
&mut self,
data: &[u8],
pos: &mut usize,
timeout: Duration
) -> Result<(), TimeoutIoError>
&mut self,
data: &[u8],
pos: &mut usize,
timeout: Duration
) -> Result<(), TimeoutIoError>
Executes one write
-operation to write as much bytes as possible from data[*pos..]
and adjusts pos
accordingly
This is especially useful in packet-based contexts where write
-operations are atomic (like
in UDP)
Note: This function catches all interal timeouts/interrupts and returns only if there was
either one successful write
-operation or the timeout
was hit or a non-recoverable error
occurred.
Warning: self
must non-blocking or the function won't work as expected
fn try_write_exact(
&mut self,
data: &[u8],
pos: &mut usize,
timeout: Duration
) -> Result<(), TimeoutIoError>
&mut self,
data: &[u8],
pos: &mut usize,
timeout: Duration
) -> Result<(), TimeoutIoError>
Reads until buf[*pos..]
has been written completely and adjusts pos
on every successful
write
-call (so that you can continue seamlessly on TimedOut
-errors etc.)
This is especially useful in stream-based contexts where partial-write
-calls are common
(like in TCP)
Note: This function catches all interal timeouts/interrupts and returns only if either
data
has been filled completely or the timeout
was hit or a non-recoverable error
occurred.
Warning: self
must non-blocking or the function won't work as expected