Struct tokio_io_timeout::TimeoutStream
source · pub struct TimeoutStream<S> { /* private fields */ }
Expand description
A stream which applies read and write timeouts to an inner stream.
Implementations§
source§impl<S> TimeoutStream<S>where
S: AsyncRead + AsyncWrite,
impl<S> TimeoutStream<S>where
S: AsyncRead + AsyncWrite,
sourcepub fn new(stream: S) -> TimeoutStream<S>
pub fn new(stream: S) -> TimeoutStream<S>
Returns a new TimeoutStream
wrapping the specified stream.
There is initially no read or write timeout.
sourcepub fn read_timeout(&self) -> Option<Duration>
pub fn read_timeout(&self) -> Option<Duration>
Returns the current read timeout.
sourcepub fn set_read_timeout(&mut self, timeout: Option<Duration>)
pub fn set_read_timeout(&mut self, timeout: Option<Duration>)
Sets the read timeout.
This can only be used before the stream is pinned; use
set_read_timeout_pinned
otherwise.
sourcepub fn set_read_timeout_pinned(self: Pin<&mut Self>, timeout: Option<Duration>)
pub fn set_read_timeout_pinned(self: Pin<&mut Self>, timeout: Option<Duration>)
Sets the read timeout.
This will reset any pending read timeout. Use set_read_timeout
instead if the stream
has not yet been pinned.
sourcepub fn write_timeout(&self) -> Option<Duration>
pub fn write_timeout(&self) -> Option<Duration>
Returns the current write timeout.
sourcepub fn set_write_timeout(&mut self, timeout: Option<Duration>)
pub fn set_write_timeout(&mut self, timeout: Option<Duration>)
Sets the write timeout.
This can only be used before the stream is pinned; use
set_write_timeout_pinned
otherwise.
sourcepub fn set_write_timeout_pinned(self: Pin<&mut Self>, timeout: Option<Duration>)
pub fn set_write_timeout_pinned(self: Pin<&mut Self>, timeout: Option<Duration>)
Sets the write timeout.
This will reset any pending write timeout. Use set_write_timeout
instead if the
stream has not yet been pinned.
sourcepub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut S>
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut S>
Returns a pinned mutable reference to the inner stream.
sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Consumes the stream, returning the inner stream.
Trait Implementations§
source§impl<S> AsyncRead for TimeoutStream<S>where
S: AsyncRead + AsyncWrite,
impl<S> AsyncRead for TimeoutStream<S>where
S: AsyncRead + AsyncWrite,
source§impl<S> AsyncWrite for TimeoutStream<S>where
S: AsyncRead + AsyncWrite,
impl<S> AsyncWrite for TimeoutStream<S>where
S: AsyncRead + AsyncWrite,
source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf
into the object. Read moresource§fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
source§fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize>>
poll_write
, except that it writes from a slice of buffers. Read moresource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read moresource§impl<S: Debug> Debug for TimeoutStream<S>
impl<S: Debug> Debug for TimeoutStream<S>
impl<'__pin, S> Unpin for TimeoutStream<S>where
__Origin<'__pin, S>: Unpin,
Auto Trait Implementations§
impl<S> !Freeze for TimeoutStream<S>
impl<S> !RefUnwindSafe for TimeoutStream<S>
impl<S> Send for TimeoutStream<S>where
S: Send,
impl<S> Sync for TimeoutStream<S>where
S: Sync,
impl<S> !UnwindSafe for TimeoutStream<S>
Blanket Implementations§
source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
source§fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf
. Read moresource§fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
source§fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
source§fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
source§fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
source§fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
source§fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
source§fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
source§fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
source§fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
source§fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
source§fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
source§fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
source§fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
source§fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
source§fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
source§fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
source§fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
source§fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
source§fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
source§fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
source§fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
source§fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
source§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
buf
. Read more