Struct async_bincode::tokio::AsyncBincodeWriter
source · [−]pub struct AsyncBincodeWriter<W, T, D> { /* private fields */ }
Expand description
A wrapper around an asynchronous sink that accepts, serializes, and sends bincode-encoded values.
To use, provide a reader that implements
tokio::io::AsyncWrite
,
and then use futures_sink::Sink
to send values.
Note that an AsyncBincodeWriter
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 AsyncBincodeWriter::for_async
.
Implementations
sourceimpl<W, T, D> AsyncBincodeWriter<W, T, D>
impl<W, T, D> AsyncBincodeWriter<W, T, D>
sourcepub fn get_ref(&self) -> &W
pub fn get_ref(&self) -> &W
Gets a reference to the underlying writer.
It is inadvisable to directly write to the underlying writer.
sourcepub fn get_mut(&mut self) -> &mut W
pub fn get_mut(&mut self) -> &mut W
Gets a mutable reference to the underlying writer.
It is inadvisable to directly write to the underlying writer.
sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Unwraps this AsyncBincodeWriter
, returning the underlying writer.
Note that any leftover serialized data that has not yet been sent is lost.
sourceimpl<W, T> AsyncBincodeWriter<W, T, SyncDestination>
impl<W, T> AsyncBincodeWriter<W, T, SyncDestination>
sourcepub fn for_async(self) -> AsyncBincodeWriter<W, T, AsyncDestination>
pub fn for_async(self) -> AsyncBincodeWriter<W, T, AsyncDestination>
Make this writer include the serialized data’s size before each serialized value.
This is necessary for compatibility with AsyncBincodeReader
.
sourceimpl<W, T> AsyncBincodeWriter<W, T, AsyncDestination>
impl<W, T> AsyncBincodeWriter<W, T, AsyncDestination>
sourcepub fn for_sync(self) -> AsyncBincodeWriter<W, T, SyncDestination>
pub fn for_sync(self) -> AsyncBincodeWriter<W, T, SyncDestination>
Make this writer only send bincode-encoded values.
This is necessary for compatibility with stock bincode
receivers.
Trait Implementations
sourceimpl<W, T> Default for AsyncBincodeWriter<W, T, SyncDestination> where
W: Default,
impl<W, T> Default for AsyncBincodeWriter<W, T, SyncDestination> where
W: Default,
sourceimpl<W, T> From<W> for AsyncBincodeWriter<W, T, SyncDestination>
impl<W, T> From<W> for AsyncBincodeWriter<W, T, SyncDestination>
sourceimpl<W, T, D> Sink<T> for AsyncBincodeWriter<W, T, D> where
T: Serialize,
W: AsyncWrite + Unpin,
Self: BincodeWriterFor<T>,
impl<W, T, D> Sink<T> for AsyncBincodeWriter<W, T, D> where
T: Serialize,
W: AsyncWrite + Unpin,
Self: BincodeWriterFor<T>,
sourcefn poll_ready(
self: Pin<&mut Self>,
_: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
fn poll_ready(
self: Pin<&mut Self>,
_: &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: T) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: T) -> 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
impl<W, T, D> Unpin for AsyncBincodeWriter<W, T, D> where
W: Unpin,
Auto Trait Implementations
impl<W, T, D> RefUnwindSafe for AsyncBincodeWriter<W, T, D> where
D: RefUnwindSafe,
T: RefUnwindSafe,
W: RefUnwindSafe,
impl<W, T, D> Send for AsyncBincodeWriter<W, T, D> where
D: Send,
T: Send,
W: Send,
impl<W, T, D> Sync for AsyncBincodeWriter<W, T, D> where
D: Sync,
T: Sync,
W: Sync,
impl<W, T, D> UnwindSafe for AsyncBincodeWriter<W, T, D> where
D: UnwindSafe,
T: 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