Trait scoped_stream_sink::StreamSinkExt

source ·
pub trait StreamSinkExt<SendItem, RecvItem = SendItem>: StreamSink<SendItem, RecvItem> {
    // Provided methods
    fn map_send<F, I>(self, f: F) -> MapSend<Self, F, SendItem>
       where Self: Sized,
             F: FnMut(SendItem) -> I { ... }
    fn map_recv<F, I>(self, f: F) -> MapRecv<Self, F, I>
       where Self: Sized,
             F: FnMut(I) -> RecvItem { ... }
    fn map_error<F, E>(self, f: F) -> MapError<Self, F>
       where Self: Sized,
             F: FnMut(Self::Error) -> E { ... }
    fn error_cast<E>(self) -> ErrorCast<Self, E>
       where Self: Sized,
             Self::Error: Into<E> { ... }
    fn chain<Other, Item>(self, other: Other) -> Chain<Self, Other, SendItem>
       where Self: Sized,
             Other: StreamSink<Item, SendItem, Error = Self::Error> { ... }
    fn send_one<'a>(
        self: Pin<&'a mut Self>,
        item: RecvItem,
    ) -> SendOne<'a, Self, SendItem, RecvItem, Self::Error> { ... }
    fn send_iter<'a, I: IntoIterator<Item = RecvItem>>(
        self: Pin<&'a mut Self>,
        iter: I,
    ) -> SendIter<'a, Self, SendItem, RecvItem, I::IntoIter, Self::Error> { ... }
    fn send_try_iter<'a, I: IntoIterator<Item = Result<RecvItem, Self::Error>>>(
        self: Pin<&'a mut Self>,
        iter: I,
    ) -> SendTryIter<'a, Self, SendItem, RecvItem, I::IntoIter, Self::Error> { ... }
    fn close<'a>(self: Pin<&'a mut Self>) -> Close<'a, Self, SendItem, RecvItem> { ... }
    fn ready<'a>(self: Pin<&'a mut Self>) -> Ready<'a, Self, SendItem, RecvItem>  { ... }
    fn try_send_one<'a, F: FnOnce() -> RecvItem>(
        self: Pin<&'a mut Self>,
        f: F,
    ) -> TrySendOne<'a, Self, SendItem, F>  { ... }
    fn try_send_future<'a, F: Future<Output = Result<RecvItem, Self::Error>>>(
        self: Pin<&'a mut Self>,
        fut: F,
    ) -> TrySendFuture<'a, Self, SendItem, F>  { ... }
}
Expand description

Extension trait for StreamSink. Contains helper methods for using StreamSink.

Provided Methods§

source

fn map_send<F, I>(self, f: F) -> MapSend<Self, F, SendItem>
where Self: Sized, F: FnMut(SendItem) -> I,

Maps the SendItem.

source

fn map_recv<F, I>(self, f: F) -> MapRecv<Self, F, I>
where Self: Sized, F: FnMut(I) -> RecvItem,

Maps the RecvItem.

source

fn map_error<F, E>(self, f: F) -> MapError<Self, F>
where Self: Sized, F: FnMut(Self::Error) -> E,

Maps the error type.

source

fn error_cast<E>(self) -> ErrorCast<Self, E>
where Self: Sized, Self::Error: Into<E>,

Cast the error type.

source

fn chain<Other, Item>(self, other: Other) -> Chain<Self, Other, SendItem>
where Self: Sized, Other: StreamSink<Item, SendItem, Error = Self::Error>,

Chain two StreamSink.

If either of the StreamSink ends, the other one will try to be closed. Some data may gets lost because of that.

source

fn send_one<'a>( self: Pin<&'a mut Self>, item: RecvItem, ) -> SendOne<'a, Self, SendItem, RecvItem, Self::Error>

Send one item.

The resulting Stream may be dropped at anytime, with only consequence is loss of item. To not lose the item, use try_send_one.

source

fn send_iter<'a, I: IntoIterator<Item = RecvItem>>( self: Pin<&'a mut Self>, iter: I, ) -> SendIter<'a, Self, SendItem, RecvItem, I::IntoIter, Self::Error>

Send items from an IntoIterator.

The resulting Stream may be dropped at anytime, with no loss of item.

source

fn send_try_iter<'a, I: IntoIterator<Item = Result<RecvItem, Self::Error>>>( self: Pin<&'a mut Self>, iter: I, ) -> SendTryIter<'a, Self, SendItem, RecvItem, I::IntoIter, Self::Error>

Send items from a fallible IntoIterator.

The resulting Stream may be dropped at anytime, with no loss of item.

source

fn close<'a>(self: Pin<&'a mut Self>) -> Close<'a, Self, SendItem, RecvItem>

Closes the StreamSink.

You must handle all items that came out of the resulting Stream.

source

fn ready<'a>(self: Pin<&'a mut Self>) -> Ready<'a, Self, SendItem, RecvItem>

Polls until it’s ready. It is safe drop the Future before it’s ready (cancel-safety).

Possible return value (after awaited):

  • Err(error) : Error happened.
  • Ok((None, false)) : StreamSink is closed.
  • Ok((Some(item), false)) : An item is sent.
  • Ok((None, true)) : Ready to receive item.
  • Ok((Some(item), true)) : Item is sent and it’s ready to receive another item.
source

fn try_send_one<'a, F: FnOnce() -> RecvItem>( self: Pin<&'a mut Self>, f: F, ) -> TrySendOne<'a, Self, SendItem, F>

Try to send an item. It is safe to drop the Future before it’s ready.

source

fn try_send_future<'a, F: Future<Output = Result<RecvItem, Self::Error>>>( self: Pin<&'a mut Self>, fut: F, ) -> TrySendFuture<'a, Self, SendItem, F>

Try to send an item using Future. It is cancen-safe if and only if the inner Future is also cancel-safe.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<SI, RI, T> StreamSinkExt<SI, RI> for T
where T: StreamSink<SI, RI>,