Struct async_io_stream::IoStream [−][src]
pub struct IoStream<St, I> where
St: Unpin, { /* fields omitted */ }
Expand description
A wrapper over a TryStream + Sink that implements [AsyncRead
]/[AsyncWrite
] and [AsyncBufRead
].
See the readme for more information.
Implements tokio::io::AsyncRead
and tokio::io::AsyncWrite
when the tokio_io
feature is enabled.
Implementations
Trait Implementations
Attempt to return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
Attempt to read from the AsyncRead
into buf
. Read more
This impl requires the tokio_io
feature.
Errors
The following errors can be returned when writing to the stream:
-
io::ErrorKind::NotConnected
: This means that the connection is already closed. You should drop it. It is safe to drop the underlying connection. -
io::ErrorKind::InvalidData
: This means that a tungstenite::error::Capacity occurred. This means that you send in a buffer bigger than the maximum message size configured on the underlying websocket connection. If you did not set it manually, the default for tungstenite is 64MB. -
other std::io::Error’s generally mean something went wrong on the underlying transport. Consider these fatal and just drop the connection.
Will always flush the underlying socket. Will always create an entire Websocket message from every write, so call with a sufficiently large buffer if you have performance problems.
Attempt to write bytes from bufs
into the object using vectored
IO operations. Read more
Attempt to flush the object, ensuring that any buffered data reach their destination. Read more
Attempt to write bytes from buf
into the object. Read more
Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
Like poll_write
, except that it writes from a slice of buffers. Read more
Determines if this writer has an efficient poll_write_vectored
implementation. Read more
Mutably borrows from an owned value. Read more
This impl requires the map_pharos
feature.
type Error = <St as Observable<Ev>>::Error
type Error = <St as Observable<Ev>>::Error
The error type that is returned if observing is not possible. Read more
impl<St, I, Ev> ObservableLocal<Ev> for IoStream<St, I> where
St: Sink<I, Error = Error> + TryStream<Ok = I, Error = Error> + ObservableLocal<Ev> + Unpin,
Ev: Clone + Send + 'static,
This is supported on crate feature map_pharos
only.
impl<St, I, Ev> ObservableLocal<Ev> for IoStream<St, I> where
St: Sink<I, Error = Error> + TryStream<Ok = I, Error = Error> + ObservableLocal<Ev> + Unpin,
Ev: Clone + Send + 'static,
map_pharos
only.This impl requires the map_pharos
feature.
type Error = <St as ObservableLocal<Ev>>::Error
type Error = <St as ObservableLocal<Ev>>::Error
The error type that is returned if observing is not possible. Read more
Add an observer to the observable. Options allow chosing the channel type and to filter events with a predicate. Read more
Auto Trait Implementations
impl<St, I> !RefUnwindSafe for IoStream<St, I>
impl<St, I> !UnwindSafe for IoStream<St, I>
Blanket Implementations
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
Creates a future which will wait for a non-empty buffer to be available from this I/O object or EOF to be reached. Read more
fn consume_unpin(&mut self, amt: usize) where
Self: Unpin,
fn consume_unpin(&mut self, amt: usize) where
Self: Unpin,
Creates a future which will read all the bytes associated with this I/O
object into buf
until the delimiter byte
or EOF is reached.
This method is the async equivalent to BufRead::read_until
. Read more
Creates a future which will read all the bytes associated with this I/O
object into buf
until a newline (the 0xA byte) or EOF is reached,
This method is the async equivalent to BufRead::read_line
. Read more
fn lines(self) -> Lines<Self>
fn lines(self) -> Lines<Self>
Returns a stream over the lines of this reader.
This method is the async equivalent to BufRead::lines
. Read more
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
Creates an adaptor which will chain this stream with another. Read more
Tries to read some bytes directly into the given buf
in asynchronous
manner, returning a future type. Read more
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
Creates a future which will read from the AsyncRead
into bufs
using vectored
IO operations. Read more
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
Creates a future which will read exactly enough bytes to fill buf
,
returning an error if end of file (EOF) is hit sooner. Read more
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes from this AsyncRead
. Read more
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes from this AsyncRead
. Read more
Helper method for splitting this read/write object into two halves. Read more
impl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
Creates a future which will entirely flush this AsyncWrite
. Read more
Creates a future which will entirely close this AsyncWrite
.
Creates a future which will write bytes from buf
into the object. Read more
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self> where
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self> where
Self: Unpin,
Creates a future which will write bytes from bufs
into the object using vectored
IO operations. Read more
Write data into this object. Read more
Mutably borrows from an owned value. Read more