Struct SinkWriter
struct SinkWriter<S> { ... }
Convert a Sink of byte chunks into an AsyncWrite.
Whenever you write to this SinkWriter, the supplied bytes are
forwarded to the inner Sink. When shutdown is called on this
SinkWriter, the inner sink is closed.
This adapter takes a Sink<&[u8]> and provides an AsyncWrite impl
for it. Because of the lifetime, this trait is relatively rarely
implemented. The main ways to get a Sink<&[u8]> that you can use with
this type are:
- With the codec module by implementing the
Encoder<&[u8]>trait. - By wrapping a
Sink<Bytes>in aCopyToBytes. - Manually implementing
Sink<&[u8]>directly.
The opposite conversion of implementing Sink<_> for an AsyncWrite
is done using the codec module.
Example
use Bytes;
use SinkExt;
use ;
use AsyncWriteExt;
use ;
use PollSender;
#
# async
Implementations
impl<S> SinkWriter<S>
fn new(sink: S) -> SelfCreates a new
SinkWriter.fn get_ref(self: &Self) -> &SGets a reference to the underlying sink.
fn get_mut(self: &mut Self) -> &mut SGets a mutable reference to the underlying sink.
fn into_inner(self: Self) -> SConsumes this
SinkWriter, returning the underlying sink.
impl<'__pin, S> Unpin for SinkWriter<S>
impl<R> AsyncReadExt for SinkWriter<S>
impl<S> Freeze for SinkWriter<S>
impl<S> RefUnwindSafe for SinkWriter<S>
impl<S> Send for SinkWriter<S>
impl<S> Sync for SinkWriter<S>
impl<S> UnsafeUnpin for SinkWriter<S>
impl<S> UnwindSafe for SinkWriter<S>
impl<S, E> AsyncWrite for SinkWriter<S>
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, Error>>fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>>fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>>
impl<S, T, E> TryStream for SinkWriter<S>
fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>
impl<S: $crate::fmt::Debug> Debug for SinkWriter<S>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<S: AsyncRead> AsyncRead for SinkWriter<S>
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<Result<()>>
impl<S: Stream> Stream for SinkWriter<S>
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<<Self as >::Item>>
impl<T> Any for SinkWriter<S>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for SinkWriter<S>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for SinkWriter<S>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for SinkWriter<S>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for SinkWriter<S>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for SinkWriter<S>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for SinkWriter<S>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>