[−][src]Struct async_bincode::AsyncBincodeStream
A wrapper around an asynchronous stream that receives and sends bincode-encoded values.
To use, provide a stream that implements both [AsyncWrite
] and AsyncRead
, and then use
Sink
to send values and Stream
to receive them.
Note that an AsyncBincodeStream
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 AsyncBincodeStream::for_async
.
Methods
impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>
[src]
pub fn get_ref(&self) -> &S
[src]
Gets a reference to the underlying stream.
It is inadvisable to directly read from or write to the underlying stream.
pub fn get_mut(&mut self) -> &mut S
[src]
Gets a mutable reference to the underlying stream.
It is inadvisable to directly read from or write to the underlying stream.
pub fn into_inner(self) -> S
[src]
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.
impl<S, R, W, D> AsyncBincodeStream<S, R, W, D>
[src]
pub fn for_async(self) -> AsyncBincodeStream<S, R, W, AsyncDestination>
[src]
Make this stream include the serialized data's size before each serialized value.
This is necessary for compatability with a remote AsyncBincodeReader
.
pub fn for_sync(self) -> AsyncBincodeStream<S, R, W, SyncDestination>
[src]
Make this stream only send bincode-encoded values.
This is necessary for compatability with stock bincode
receivers.
impl<R, W, D> AsyncBincodeStream<TcpStream, R, W, D>
[src]
pub fn tcp_split(
&mut self
) -> (AsyncBincodeReader<ReadHalf, R>, AsyncBincodeWriter<WriteHalf, W, D>)
[src]
&mut self
) -> (AsyncBincodeReader<ReadHalf, R>, AsyncBincodeWriter<WriteHalf, W, D>)
Split a TCP-based stream into a read half and a write half.
This is more performant than using a lock-based split like the one provided by tokio-io
or futures-util
since we know that reads and writes to a TcpStream
can continue
concurrently.
Any partially sent or received state is preserved.
Trait Implementations
impl<S, R, W> From<S> for AsyncBincodeStream<S, R, W, SyncDestination>
[src]
impl<S, R, W> Default for AsyncBincodeStream<S, R, W, SyncDestination> where
S: Default,
[src]
S: Default,
impl<S: Debug, R: Debug, W: Debug, D: Debug> Debug for AsyncBincodeStream<S, R, W, D>
[src]
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>>,
[src]
S: Unpin,
AsyncBincodeReader<InternalAsyncWriter<S, W, D>, R>: Stream<Item = Result<R, Error>>,
type Item = Result<R, Error>
Values yielded by the stream.
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<S, R, W, D> Sink<W> for AsyncBincodeStream<S, R, W, D> where
S: Unpin,
AsyncBincodeWriter<S, W, D>: Sink<W, Error = Error>,
[src]
S: Unpin,
AsyncBincodeWriter<S, W, D>: Sink<W, Error = Error>,
type Error = Error
The type of value produced by the sink when an error occurs.
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::Error>>
fn start_send(self: Pin<&mut Self>, item: W) -> Result<(), Self::Error>
[src]
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::Error>>
fn poll_close(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::Error>>
Auto Trait Implementations
impl<S, R, W, D> Send for AsyncBincodeStream<S, R, W, D> where
D: Send,
R: Send,
S: Send,
W: Send,
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,
D: Sync,
R: Sync,
S: Sync,
W: Sync,
impl<S, R, W, D> Unpin for AsyncBincodeStream<S, R, W, D> where
S: Unpin,
S: Unpin,
impl<S, R, W, D> UnwindSafe for AsyncBincodeStream<S, R, W, D> where
D: UnwindSafe,
R: UnwindSafe,
S: UnwindSafe,
W: UnwindSafe,
D: UnwindSafe,
R: UnwindSafe,
S: UnwindSafe,
W: UnwindSafe,
impl<S, R, W, D> RefUnwindSafe for AsyncBincodeStream<S, R, W, D> where
D: RefUnwindSafe,
R: RefUnwindSafe,
S: RefUnwindSafe,
W: RefUnwindSafe,
D: RefUnwindSafe,
R: RefUnwindSafe,
S: RefUnwindSafe,
W: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<S, T, E> TryStream for S where
S: Stream<Item = Result<T, E>> + ?Sized,
[src]
S: Stream<Item = Result<T, E>> + ?Sized,