[][src]Struct futures_ext::SinkToAsyncWrite

pub struct SinkToAsyncWrite<S> { /* fields omitted */ }

Simple adapter from Sink interface to AsyncWrite interface. It can be useful to convert from the interface that supports only AsyncWrite, and get Stream as a result. See pseudocode below

fn async_write_interface(writer: &mut dyn AsyncWrite) -> BoxFuture<(), Error> {
   unimplemented!()
}

fn foo() {
   use futures::sync::mpsc;
   let (sender, receiver) = mpsc::channel(1);

   tokio::spawn(
      async_write_interface(&mut SinkToAsyncWrite::new(sender))
          .map_err(|err| {})
   );

   // receiver is a stream of values written from async_write_interface
}

Implementations

impl<S> SinkToAsyncWrite<S>[src]

pub fn new(sink: S) -> Self[src]

Return an instance of SinkToAsyncWrite wrapping a Sink

Trait Implementations

impl<E, S> AsyncWrite for SinkToAsyncWrite<S> where
    S: Sink<SinkItem = Bytes, SinkError = E>,
    E: Debug
[src]

impl<E, S> Write for SinkToAsyncWrite<S> where
    S: Sink<SinkItem = Bytes, SinkError = E>,
    E: Debug
[src]

Auto Trait Implementations

impl<S> RefUnwindSafe for SinkToAsyncWrite<S> where
    S: RefUnwindSafe

impl<S> Send for SinkToAsyncWrite<S> where
    S: Send

impl<S> Sync for SinkToAsyncWrite<S> where
    S: Sync

impl<S> Unpin for SinkToAsyncWrite<S> where
    S: Unpin

impl<S> UnwindSafe for SinkToAsyncWrite<S> where
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<W> WriteBytesExt for W where
    W: Write + ?Sized