pub struct TimeoutWriter<H> where
    H: Write + AsRawFd
{ /* private fields */ }
Expand description

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.

If any Write operation times out, the method called will return an io::ErrorKind::TimedOut variant as the value of io::Error. All other error values that would normally be produced by the underlying implementation of the Write trait could also be produced by the TimeoutWriter.

Implementations

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

Extracts the raw file descriptor. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Seek to an offset, in bytes, in a stream. Read more

Rewind to the beginning of a stream. Read more

🔬 This is a nightly-only experimental API. (seek_stream_len)

Returns the length of this stream (in bytes). Read more

Returns the current seek position from the start of the stream. Read more

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.