Struct async_bincode::futures::AsyncBincodeStream
source · pub struct AsyncBincodeStream<S, R, W, D> { /* private fields */ }
Expand description
A wrapper around an asynchronous stream that receives and sends bincode-encoded values.
To use, provide a stream that implements both
futures_io::AsyncRead
and futures_io::AsyncWrite
,
and then use futures_sink::Sink
to send values and futures_core::Stream
to
receive them.
Note that an AsyncBincodeStream
must be of the type crate::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
crate::SyncDestination
, but these can be easily toggled between using
AsyncBincodeStream::for_async
.
Implementations§
source§impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>
impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>
sourcepub fn get_ref(&self) -> &S
pub fn get_ref(&self) -> &S
Gets a reference to the underlying stream.
It is inadvisable to directly read from or write to the underlying stream.
sourcepub fn get_mut(&mut self) -> &mut S
pub fn get_mut(&mut self) -> &mut S
Gets a mutable reference to the underlying stream.
It is inadvisable to directly read from or write to the underlying stream.
sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
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.
source§impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>
impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>
sourcepub fn for_async(self) -> AsyncBincodeStream<S, R, W, AsyncDestination>
pub fn for_async(self) -> AsyncBincodeStream<S, R, W, AsyncDestination>
Make this stream include the serialized data’s size before each serialized value.
This is necessary for compatability with a remote AsyncBincodeReader
.
sourcepub fn for_sync(self) -> AsyncBincodeStream<S, R, W, SyncDestination>
pub fn for_sync(self) -> AsyncBincodeStream<S, R, W, SyncDestination>
Make this stream only send bincode-encoded values.
This is necessary for compatability with stock bincode
receivers.
Trait Implementations§
source§impl<S, R, W> Default for AsyncBincodeStream<S, R, W, SyncDestination>where
S: Default,
impl<S, R, W> Default for AsyncBincodeStream<S, R, W, SyncDestination>where
S: Default,
source§impl<S, R, W> From<S> for AsyncBincodeStream<S, R, W, SyncDestination>
impl<S, R, W> From<S> for AsyncBincodeStream<S, R, W, SyncDestination>
source§impl<S, R, W, D> Sink<W> for AsyncBincodeStream<S, R, W, D>
impl<S, R, W, D> Sink<W> for AsyncBincodeStream<S, R, W, D>
source§fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<(), Self::Error>>
Sink
to receive a value. Read moresource§fn start_send(self: Pin<&mut Self>, item: W) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: W) -> Result<(), Self::Error>
poll_ready
which returned Poll::Ready(Ok(()))
. Read more