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
sourceimpl<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.
sourceimpl<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
sourceimpl<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,
sourceimpl<S, R, W> From<S> for AsyncBincodeStream<S, R, W, SyncDestination>
impl<S, R, W> From<S> for AsyncBincodeStream<S, R, W, SyncDestination>
sourceimpl<S, R, W, D> Sink<W> for AsyncBincodeStream<S, R, W, D> where
S: Unpin,
AsyncBincodeWriter<S, W, D>: Sink<W, Error = Error>,
impl<S, R, W, D> Sink<W> for AsyncBincodeStream<S, R, W, D> where
S: Unpin,
AsyncBincodeWriter<S, W, D>: Sink<W, Error = Error>,
sourcefn 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>>
Attempts to prepare the Sink
to receive a value. Read more
sourcefn start_send(self: Pin<&mut Self>, item: W) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: W) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read more
sourceimpl<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>>,
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>>,
Auto Trait Implementations
impl<S, R, W, D> RefUnwindSafe for AsyncBincodeStream<S, R, W, D> where
D: RefUnwindSafe,
R: RefUnwindSafe,
S: RefUnwindSafe,
W: RefUnwindSafe,
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> Sync for AsyncBincodeStream<S, R, W, D> where
D: Sync,
R: Sync,
S: Sync,
W: Sync,
impl<S, R, W, D> Unpin for AsyncBincodeStream<S, R, W, D> where
S: Unpin,
impl<S, R, W, D> UnwindSafe for AsyncBincodeStream<S, R, W, D> where
D: UnwindSafe,
R: UnwindSafe,
S: UnwindSafe,
W: 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