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§
sourcefn error_cast<E>(self) -> ErrorCast<Self, E>
fn error_cast<E>(self) -> ErrorCast<Self, E>
Cast the error type.
sourcefn chain<Other, Item>(self, other: Other) -> Chain<Self, Other, SendItem>
fn chain<Other, Item>(self, other: Other) -> Chain<Self, Other, SendItem>
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.
sourcefn send_one<'a>(
self: Pin<&'a mut Self>,
item: RecvItem,
) -> SendOne<'a, Self, SendItem, RecvItem, Self::Error>
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
.
sourcefn 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_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.
sourcefn 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 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.
sourcefn close<'a>(self: Pin<&'a mut Self>) -> Close<'a, Self, SendItem, RecvItem>
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
.
sourcefn ready<'a>(self: Pin<&'a mut Self>) -> Ready<'a, Self, SendItem, RecvItem> ⓘ
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.
sourcefn try_send_one<'a, F: FnOnce() -> RecvItem>(
self: Pin<&'a mut Self>,
f: F,
) -> TrySendOne<'a, Self, SendItem, F> ⓘ
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.