Struct async_bincode::AsyncBincodeWriter
[−]
[src]
pub struct AsyncBincodeWriter<W, T, D> { /* fields omitted */ }
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
].
Methods
impl<W, T, D> AsyncBincodeWriter<W, T, D>
[src]
pub fn get_ref(&self) -> &W
[src]
Gets a reference to the underlying writer.
It is inadvisable to directly write to the underlying writer.
pub fn get_mut(&mut self) -> &mut W
[src]
Gets a mutable reference to the underlying writer.
It is inadvisable to directly write to the underlying writer.
pub fn into_inner(self) -> W
[src]
Unwraps this AsyncBincodeWriter
, returning the underlying writer.
Note that any leftover serialized data that has not yet been sent is lost.
impl<W, T> AsyncBincodeWriter<W, T, SyncDestination>
[src]
pub fn for_async(self) -> AsyncBincodeWriter<W, T, AsyncDestination>
[src]
Make this writer include the serialized data's size before each serialized value.
This is necessary for compatability with [AsyncBincodeReader
].
impl<W, T> AsyncBincodeWriter<W, T, AsyncDestination>
[src]
pub fn for_sync(self) -> AsyncBincodeWriter<W, T, SyncDestination>
[src]
Make this writer only send bincode-encoded values.
This is necessary for compatability with stock bincode
receivers.
Trait Implementations
impl<W: Debug, T: Debug, D: Debug> Debug for AsyncBincodeWriter<W, T, D>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<W, T> Default for AsyncBincodeWriter<W, T, SyncDestination> where
W: Default,
[src]
W: Default,
impl<W, T> From<W> for AsyncBincodeWriter<W, T, SyncDestination>
[src]
impl<W, T, D> Sink for AsyncBincodeWriter<W, T, D> where
T: Serialize,
W: AsyncWrite,
Self: BincodeWriterFor<T>,
[src]
T: Serialize,
W: AsyncWrite,
Self: BincodeWriterFor<T>,
type SinkItem = T
The type of value that the sink accepts.
type SinkError = Error
The type of value produced by the sink when an error occurs.
fn start_send(
&mut self,
item: Self::SinkItem
) -> Result<AsyncSink<Self::SinkItem>, Self::SinkError>
[src]
&mut self,
item: Self::SinkItem
) -> Result<AsyncSink<Self::SinkItem>, Self::SinkError>
Begin the process of sending a value to the sink. Read more
fn poll_complete(&mut self) -> Result<Async<()>, Self::SinkError>
[src]
Flush all output from this sink, if necessary. Read more
fn close(&mut self) -> Result<Async<()>, Self::SinkError>
[src]
A method to indicate that no more values will ever be pushed into this sink. Read more
fn wait(self) -> Wait<Self>
[src]
Creates a new object which will produce a synchronous sink. Read more
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>,
[src]
F: FnMut(U) -> Fut,
Fut: IntoFuture<Item = Self::SinkItem>,
<Fut as IntoFuture>::Error: From<Self::SinkError>,
Composes a function in front of the sink. Read more
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>,
[src]
F: FnMut(U) -> St,
St: Stream<Item = Self::SinkItem, Error = Self::SinkError>,
Composes a function in front of the sink. Read more
fn sink_map_err<F, E>(self, f: F) -> SinkMapErr<Self, F> where
F: FnOnce(Self::SinkError) -> E,
[src]
F: FnOnce(Self::SinkError) -> E,
Transforms the error returned by the sink.
fn sink_from_err<E>(self) -> SinkFromErr<Self, E> where
E: From<Self::SinkError>,
[src]
E: From<Self::SinkError>,
Map this sink's error to any error implementing From
for this sink's Error
, returning a new sink. Read more
fn buffer(self, amt: usize) -> Buffer<Self>
[src]
Adds a fixed-size buffer to the current sink. Read more
fn fanout<S>(self, other: S) -> Fanout<Self, S> where
S: Sink<SinkItem = Self::SinkItem, SinkError = Self::SinkError>,
Self::SinkItem: Clone,
[src]
S: Sink<SinkItem = Self::SinkItem, SinkError = Self::SinkError>,
Self::SinkItem: Clone,
Fanout items to multiple sinks. Read more
fn flush(self) -> Flush<Self>
[src]
A future that completes when the sink has finished processing all pending requests. Read more
fn send(self, item: Self::SinkItem) -> Send<Self>
[src]
A future that completes after the given item has been fully processed into the sink, including flushing. Read more
fn send_all<S>(self, stream: S) -> SendAll<Self, S> where
S: Stream<Item = Self::SinkItem>,
Self::SinkError: From<<S as Stream>::Error>,
[src]
S: Stream<Item = Self::SinkItem>,
Self::SinkError: From<<S as Stream>::Error>,
A future that completes after the given stream has been fully processed into the sink, including flushing. Read more
Auto Trait Implementations
impl<W, T, D> Send for AsyncBincodeWriter<W, T, D> where
D: Send,
T: Send,
W: Send,
D: Send,
T: Send,
W: Send,
impl<W, T, D> Sync for AsyncBincodeWriter<W, T, D> where
D: Sync,
T: Sync,
W: Sync,
D: Sync,
T: Sync,
W: Sync,