Trait timeout_io::Writer [−][src]
pub trait Writer { fn write_oneshot(
&mut self,
data: &mut SliceQueue<u8>,
timeout: Duration
) -> Result<()>; fn write_exact(
&mut self,
data: &mut SliceQueue<u8>,
timeout: Duration
) -> Result<()>; }
A trait for writing with timeouts
Required Methods
fn write_oneshot(
&mut self,
data: &mut SliceQueue<u8>,
timeout: Duration
) -> Result<()>
&mut self,
data: &mut SliceQueue<u8>,
timeout: Duration
) -> Result<()>
Executes one write
-operation to write as much bytes as possible from data
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: This function makes self
non-blocking. It's up to you to restore the previous
state if necessary.
Parameters:
data
: The data to writetimeout
: The maximum time this function will wait forself
to become writeable
Returns either nothing or a corresponding IoError
fn write_exact(
&mut self,
data: &mut SliceQueue<u8>,
timeout: Duration
) -> Result<()>
&mut self,
data: &mut SliceQueue<u8>,
timeout: Duration
) -> Result<()>
Writes all bytes in data
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: This function makes self
non-blocking. It's up to you to restore the previous
state if necessary.
Parameters:
data
: The data to writetimeout
: The maximum time this function will wait forself
to become writeable
Returns either nothing or a corresponding IoError
Implementors
impl<T: Write + WaitForEvent> Writer for T