Struct timeout_readwrite::TimeoutWriter
[−]
[src]
pub struct TimeoutWriter<H> where
H: Write + AsRawFd, { /* fields omitted */ }The TimeoutWriter struct adds write timeouts to any writer.
The write call on a Write instance can block forever until data cannot be written.
A TimeoutWriter will wait until data can be written, up until an optional timeout,
before actually performing the write operation on the underlying writer.
Methods
impl<H> TimeoutWriter<H> where
H: Write + AsRawFd, [src]
H: Write + AsRawFd,
fn new<T: Into<Option<Duration>>>(handle: H, timeout: T) -> TimeoutWriter<H>[src]
Create a new TimeoutWriter with an optional timeout.
Examples
This first example creates the TimeoutWriter with a 5-second timeout.
use timeout_readwrite::TimeoutWriter; use std::fs::File; use std::time::Duration; let mut f = File::open("file.txt")?; let mut wtr = TimeoutWriter::new(f, Duration::new(5, 0));
This example creates the TimeoutWriter without a timeout at all.
use timeout_readwrite::TimeoutWriter; use std::fs::File; use std::time::Duration; let mut f = File::open("file.txt")?; let mut wtr = TimeoutWriter::new(f, None);
Trait Implementations
impl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd, [src]
H: Write + AsRawFd,
fn write(&mut self, buf: &[u8]) -> Result<usize>[src]
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>[src]
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>1.0.0[src]
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>1.0.0[src]
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self1.0.0[src]
Creates a "by reference" adaptor for this instance of Write. Read more
impl<H> Clone for TimeoutWriter<H> where
H: Write + AsRawFd + Clone, [src]
H: Write + AsRawFd + Clone,
fn clone(&self) -> TimeoutWriter<H>[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more