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]

[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]

[src]

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

[src]

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

1.0.0
[src]

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

1.0.0
[src]

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

1.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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more