Struct timeout_readwrite::writer::TimeoutWriter
source · [−]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
sourceimpl<H> TimeoutWriter<H> where
H: Write + AsRawFd,
impl<H> TimeoutWriter<H> where
H: Write + AsRawFd,
sourcepub fn new<T: Into<Option<Duration>>>(handle: H, timeout: T) -> TimeoutWriter<H>ⓘNotable traits for TimeoutWriter<H>impl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd,
pub fn new<T: Into<Option<Duration>>>(handle: H, timeout: T) -> TimeoutWriter<H>ⓘNotable traits for TimeoutWriter<H>impl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd,
H: Write + AsRawFd,
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
sourceimpl<H> AsRawFd for TimeoutWriter<H> where
H: Write + AsRawFd,
impl<H> AsRawFd for TimeoutWriter<H> where
H: Write + AsRawFd,
sourceimpl<H> Clone for TimeoutWriter<H> where
H: Write + AsRawFd + Clone,
impl<H> Clone for TimeoutWriter<H> where
H: Write + AsRawFd + Clone,
sourcefn clone(&self) -> TimeoutWriter<H>ⓘNotable traits for TimeoutWriter<H>impl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd,
fn clone(&self) -> TimeoutWriter<H>ⓘNotable traits for TimeoutWriter<H>impl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd,
H: Write + AsRawFd,
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<H> Seek for TimeoutWriter<H> where
H: Write + AsRawFd + Seek,
impl<H> Seek for TimeoutWriter<H> where
H: Write + AsRawFd + Seek,
sourcefn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
1.55.0 · sourcefn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Rewind to the beginning of a stream. Read more
sourceimpl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd,
impl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd,
sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)Determines if this Writer has an efficient write_vectored
implementation. Read more
1.0.0 · sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations
impl<H> RefUnwindSafe for TimeoutWriter<H> where
H: RefUnwindSafe,
impl<H> Send for TimeoutWriter<H> where
H: Send,
impl<H> Sync for TimeoutWriter<H> where
H: Sync,
impl<H> Unpin for TimeoutWriter<H> where
H: Unpin,
impl<H> UnwindSafe for TimeoutWriter<H> where
H: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<H> TimeoutWriteExt<H> for H where
H: Write + AsRawFd,
impl<H> TimeoutWriteExt<H> for H where
H: Write + AsRawFd,
fn with_timeout<T>(self, timeout: T) -> TimeoutWriter<H>ⓘNotable traits for TimeoutWriter<H>impl<H> Write for TimeoutWriter<H> where
H: Write + AsRawFd, where
T: Into<Option<Duration>>,
H: Write + AsRawFd,