Struct async_bincode::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 writer that implements futures::AsyncWrite
, and then use futures::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§
source§impl<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.
source§impl<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 compatability with [AsyncBincodeReader
].
source§impl<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 compatability with stock bincode
receivers.
Trait Implementations§
source§impl<W, T> Default for AsyncBincodeWriter<W, T, SyncDestination>where
W: Default,
impl<W, T> Default for AsyncBincodeWriter<W, T, SyncDestination>where
W: Default,
source§impl<W, T> From<W> for AsyncBincodeWriter<W, T, SyncDestination>
impl<W, T> From<W> for AsyncBincodeWriter<W, T, SyncDestination>
source§impl<W, T, D> Sink for AsyncBincodeWriter<W, T, D>where
T: Serialize,
W: AsyncWrite,
Self: BincodeWriterFor<T>,
impl<W, T, D> Sink for AsyncBincodeWriter<W, T, D>where
T: Serialize,
W: AsyncWrite,
Self: BincodeWriterFor<T>,
§type SinkError = Box<ErrorKind, Global>
type SinkError = Box<ErrorKind, Global>
source§fn start_send(
&mut self,
item: Self::SinkItem
) -> Result<AsyncSink<Self::SinkItem>, Self::SinkError>
fn start_send(
&mut self,
item: Self::SinkItem
) -> Result<AsyncSink<Self::SinkItem>, Self::SinkError>
source§fn poll_complete(&mut self) -> Result<Async<()>, Self::SinkError>
fn poll_complete(&mut self) -> Result<Async<()>, Self::SinkError>
source§fn close(&mut self) -> Result<Async<()>, Self::SinkError>
fn close(&mut self) -> Result<Async<()>, Self::SinkError>
source§fn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
source§fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
fn with<U, F, Fut>(self, f: F) -> With<Self, U, F, Fut>where
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Self: Sized,
source§fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
fn with_flat_map<U, F, St>(self, f: F) -> WithFlatMap<Self, U, F, St>where
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Self: Sized,
source§fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::SinkError) -> E,
Self: Sized,
source§fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
fn sink_from_err<E>(self) -> SinkFromErr<Self, E>where
E: From<Self::SinkError>,
Self: Sized,
From
for this sink’s
Error
, returning a new sink. Read more