[][src]Struct async_bincode::AsyncBincodeStream

pub struct AsyncBincodeStream<S, R, W, D> { /* fields omitted */ }

A wrapper around an asynchronous stream that receives and sends bincode-encoded values.

To use, provide a stream that implements both tokio::io::AsyncWrite and tokio::io::AsyncRead, and then use futures::Sink to send values and futures::Stream to receive them.

Note that an AsyncBincodeStream must be of the type AsyncDestination in order to be compatible with an AsyncBincodeReader on the remote end (recall that it requires the serialized size prefixed to the serialized data). The default is SyncDestination, but these can be easily toggled between using AsyncBincodeStream::for_async.

Methods

impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>[src]

pub fn get_ref(&self) -> &S[src]

Gets a reference to the underlying stream.

It is inadvisable to directly read from or write to the underlying stream.

pub fn get_mut(&mut self) -> &mut S[src]

Gets a mutable reference to the underlying stream.

It is inadvisable to directly read from or write to the underlying stream.

pub fn into_inner(self) -> S[src]

Unwraps this AsyncBincodeStream, returning the underlying stream.

Note that any leftover serialized data that has not yet been sent, or received data that has not yet been deserialized, is lost.

impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>[src]

pub fn for_async(self) -> AsyncBincodeStream<S, R, W, AsyncDestination>[src]

Make this stream include the serialized data's size before each serialized value.

This is necessary for compatability with a remote AsyncBincodeReader.

pub fn for_sync(self) -> AsyncBincodeStream<S, R, W, SyncDestination>[src]

Make this stream only send bincode-encoded values.

This is necessary for compatability with stock bincode receivers.

impl<R, W, D> AsyncBincodeStream<TcpStream, R, W, D>[src]

pub fn split(
    self
) -> (AsyncBincodeReader<TcpStreamReadHalf, R>, AsyncBincodeWriter<TcpStreamWriteHalf, W, D>)
[src]

Split this async stream into a write half and a read half.

Any partially sent or received state is preserved.

Trait Implementations

impl<S, R, W> Default for AsyncBincodeStream<S, R, W, SyncDestination> where
    S: Default
[src]

impl<S, R, W> From<S> for AsyncBincodeStream<S, R, W, SyncDestination>[src]

impl<S: Debug, R: Debug, W: Debug, D: Debug> Debug for AsyncBincodeStream<S, R, W, D>[src]

impl<S, R, W, D> Stream for AsyncBincodeStream<S, R, W, D> where
    S: Unpin,
    AsyncBincodeReader<InternalAsyncWriter<S, W, D>, R>: Stream<Item = Result<R, Error>>, 
[src]

type Item = Result<R, Error>

Values yielded by the stream.

impl<S, R, W, D> Sink<W> for AsyncBincodeStream<S, R, W, D> where
    S: Unpin,
    AsyncBincodeWriter<S, W, D>: Sink<W, Error = Error>, 
[src]

type Error = Error

The type of value produced by the sink when an error occurs.

Auto Trait Implementations

impl<S, R, W, D> Unpin for AsyncBincodeStream<S, R, W, D> where
    S: Unpin

impl<S, R, W, D> Sync for AsyncBincodeStream<S, R, W, D> where
    D: Sync,
    R: Sync,
    S: Sync,
    W: Sync

impl<S, R, W, D> Send for AsyncBincodeStream<S, R, W, D> where
    D: Send,
    R: Send,
    S: Send,
    W: Send

impl<S, R, W, D> UnwindSafe for AsyncBincodeStream<S, R, W, D> where
    D: UnwindSafe,
    R: UnwindSafe,
    S: UnwindSafe,
    W: UnwindSafe

impl<S, R, W, D> RefUnwindSafe for AsyncBincodeStream<S, R, W, D> where
    D: RefUnwindSafe,
    R: RefUnwindSafe,
    S: RefUnwindSafe,
    W: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<T, Item> SinkExt<Item> for T where
    T: Sink<Item> + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]