[−][src]Trait futures_sink::Sink
A Sink
is a value into which other values can be sent, asynchronously.
Basic examples of sinks include the sending side of:
- Channels
- Sockets
- Pipes
In addition to such "primitive" sinks, it's typical to layer additional functionality, such as buffering, on top of an existing sink.
Sending to a sink is "asynchronous" in the sense that the value may not be sent in its entirety immediately. Instead, values are sent in a two-phase way: first by initiating a send, and then by polling for completion. This two-phase setup is analogous to buffered writing in synchronous code, where writes often succeed immediately, but internally are buffered and are actually written only upon flushing.
In addition, the Sink
may be full, in which case it is not even possible
to start the sending process.
As with Future
and Stream
, the Sink
trait is built from a few core
required methods, and a host of default methods for working in a
higher-level way. The Sink::send_all
combinator is of particular
importance: you can use it to send an entire stream to a sink, which is
the simplest way to ultimately consume a stream.
Associated Types
Required methods
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[+]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError>
[+]
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[+]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[+]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
Implementations on Foreign Types
impl<S: ?Sized + Sink<Item> + Unpin, Item, '_> Sink<Item> for &'_ mut S
[src][−]
type SinkError = S::SinkError
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
impl<P, Item> Sink<Item> for Pin<P> where
P: DerefMut + Unpin,
P::Target: Sink<Item>,
[src][−]
P: DerefMut + Unpin,
P::Target: Sink<Item>,
type SinkError = <P::Target as Sink<Item>>::SinkError
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
impl<T> Sink<T> for Sender<T>
[src][−]
type SinkError = SendError
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, msg: T) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
impl<T> Sink<T> for UnboundedSender<T>
[src][−]
type SinkError = SendError
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, msg: T) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
impl<T, '_> Sink<T> for &'_ UnboundedSender<T>
[src][−]
type SinkError = SendError
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, msg: T) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
impl<T> Sink<T> for Vec<T>
[src][−]
type SinkError = VecSinkError
fn poll_ready(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
impl<T> Sink<T> for VecDeque<T>
[src][−]
type SinkError = VecSinkError
fn poll_ready(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
_: &mut Context
) -> Poll<Result<(), Self::SinkError>>
impl<S: ?Sized + Sink<Item> + Unpin, Item> Sink<Item> for Box<S>
[src][−]
type SinkError = S::SinkError
fn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError>
[src]
fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
fn poll_close(
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
[src]
self: Pin<&mut Self>,
cx: &mut Context
) -> Poll<Result<(), Self::SinkError>>
Implementors
impl<A, B, Item> Sink<Item> for Either<A, B> where
A: Sink<Item>,
B: Sink<Item, SinkError = A::SinkError>,
impl<A, B, Item> Sink<Item> for Either<A, B> where
A: Sink<Item>,
B: Sink<Item, SinkError = A::SinkError>,
impl<Fut, Si, Item> Sink<Item> for FlattenSink<Fut, Si> where
Fut: TryFuture<Ok = Si>,
Si: Sink<Item, SinkError = Fut::Error>,
impl<Fut, Si, Item> Sink<Item> for FlattenSink<Fut, Si> where
Fut: TryFuture<Ok = Si>,
Si: Sink<Item, SinkError = Fut::Error>,
impl<S, Item> Sink<Item> for Enumerate<S> where
S: Stream + Sink<Item>,
impl<S, Item> Sink<Item> for Enumerate<S> where
S: Stream + Sink<Item>,
impl<S, Fut, F, Item> Sink<Item> for Filter<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item) -> Fut,
Fut: Future<Output = bool>,
impl<S, Fut, F, Item> Sink<Item> for Filter<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item) -> Fut,
Fut: Future<Output = bool>,
impl<S, Fut, F, Item> Sink<Item> for FilterMap<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(S::Item) -> Fut,
Fut: Future,
impl<S, Fut, F, Item> Sink<Item> for FilterMap<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(S::Item) -> Fut,
Fut: Future,
impl<S, Item> Sink<Item> for Flatten<S> where
S: Stream + Sink<Item>,
S::Item: Stream,
impl<S, Item> Sink<Item> for Flatten<S> where
S: Stream + Sink<Item>,
S::Item: Stream,
impl<S: Stream + Sink<Item>, Item> Sink<Item> for Fuse<S>
impl<S: Stream + Sink<Item>, Item> Sink<Item> for Fuse<S>
impl<S, F, Item> Sink<Item> for Inspect<S, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item),
impl<S, F, Item> Sink<Item> for Inspect<S, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item),
impl<S, F, T, Item> Sink<Item> for Map<S, F> where
S: Stream + Sink<Item>,
F: FnMut(S::Item) -> T,
impl<S, F, T, Item> Sink<Item> for Map<S, F> where
S: Stream + Sink<Item>,
F: FnMut(S::Item) -> T,
impl<S, Item> Sink<Item> for Peekable<S> where
S: Sink<Item> + Stream,
impl<S, Item> Sink<Item> for Peekable<S> where
S: Sink<Item> + Stream,
impl<S, Item> Sink<Item> for Skip<S> where
S: Stream + Sink<Item>,
impl<S, Item> Sink<Item> for Skip<S> where
S: Stream + Sink<Item>,
impl<S, Fut, F, Item> Sink<Item> for SkipWhile<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item) -> Fut,
Fut: Future<Output = bool>,
impl<S, Fut, F, Item> Sink<Item> for SkipWhile<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item) -> Fut,
Fut: Future<Output = bool>,
impl<S, Item> Sink<Item> for Take<S> where
S: Stream + Sink<Item>,
impl<S, Item> Sink<Item> for Take<S> where
S: Stream + Sink<Item>,
impl<S, Fut, F, Item> Sink<Item> for TakeWhile<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item) -> Fut,
Fut: Future<Output = bool>,
impl<S, Fut, F, Item> Sink<Item> for TakeWhile<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(&S::Item) -> Fut,
Fut: Future<Output = bool>,
impl<S, Fut, F, Item> Sink<Item> for Then<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(S::Item) -> Fut,
Fut: Future,
impl<S, Fut, F, Item> Sink<Item> for Then<S, Fut, F> where
S: Stream + Sink<Item>,
F: FnMut(S::Item) -> Fut,
Fut: Future,
impl<S, Item> Sink<Item> for Chunks<S> where
S: Stream + Sink<Item>,
impl<S, Item> Sink<Item> for Chunks<S> where
S: Stream + Sink<Item>,
impl<S, Item> Sink<Item> for BufferUnordered<S> where
S: Stream + Sink<Item>,
S::Item: Future,
impl<S, Item> Sink<Item> for BufferUnordered<S> where
S: Stream + Sink<Item>,
S::Item: Future,
impl<S, Item> Sink<Item> for Buffered<S> where
S: Stream + Sink<Item>,
S::Item: Future,
impl<S, Item> Sink<Item> for Buffered<S> where
S: Stream + Sink<Item>,
S::Item: Future,
impl<S: Sink<Item>, Item> Sink<Item> for SplitSink<S, Item>
impl<S: Sink<Item>, Item> Sink<Item> for SplitSink<S, Item>
impl<S, Fut, F, Item> Sink<Item> for AndThen<S, Fut, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Ok) -> Fut,
Fut: TryFuture<Error = S::Error>,
impl<S, Fut, F, Item> Sink<Item> for AndThen<S, Fut, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Ok) -> Fut,
Fut: TryFuture<Error = S::Error>,
impl<S, E, Item> Sink<Item> for ErrInto<S, E> where
S: TryStream + Sink<Item>,
S::Error: Into<E>,
impl<S, E, Item> Sink<Item> for ErrInto<S, E> where
S: TryStream + Sink<Item>,
S::Error: Into<E>,
impl<S: TryStream + Sink<Item>, Item> Sink<Item> for IntoStream<S>
impl<S: TryStream + Sink<Item>, Item> Sink<Item> for IntoStream<S>
impl<S, F, T, Item> Sink<Item> for MapOk<S, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Ok) -> T,
impl<S, F, T, Item> Sink<Item> for MapOk<S, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Ok) -> T,
impl<S, F, E, Item> Sink<Item> for MapErr<S, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Error) -> E,
impl<S, F, E, Item> Sink<Item> for MapErr<S, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Error) -> E,
impl<S, Fut, F, Item> Sink<Item> for OrElse<S, Fut, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Error) -> Fut,
Fut: TryFuture<Ok = S::Ok>,
impl<S, Fut, F, Item> Sink<Item> for OrElse<S, Fut, F> where
S: TryStream + Sink<Item>,
F: FnMut(S::Error) -> Fut,
Fut: TryFuture<Ok = S::Ok>,
impl<S, Fut, F, T, Item> Sink<Item> for TryFilterMap<S, Fut, F> where
S: TryStream + Sink<Item>,
Fut: TryFuture<Ok = Option<T>, Error = S::Error>,
F: FnMut(S::Ok) -> Fut,
impl<S, Fut, F, T, Item> Sink<Item> for TryFilterMap<S, Fut, F> where
S: TryStream + Sink<Item>,
Fut: TryFuture<Ok = Option<T>, Error = S::Error>,
F: FnMut(S::Ok) -> Fut,
impl<S, Fut, F, Item> Sink<Item> for TrySkipWhile<S, Fut, F> where
S: TryStream + Sink<Item>,
F: FnMut(&S::Ok) -> Fut,
Fut: TryFuture<Ok = bool, Error = S::Error>,
impl<S, Fut, F, Item> Sink<Item> for TrySkipWhile<S, Fut, F> where
S: TryStream + Sink<Item>,
F: FnMut(&S::Ok) -> Fut,
Fut: TryFuture<Ok = bool, Error = S::Error>,
impl<S, Item> Sink<Item> for TryBufferUnordered<S> where
S: TryStream + Sink<Item>,
S::Ok: TryFuture<Error = S::Error>,
impl<S, Item> Sink<Item> for TryBufferUnordered<S> where
S: TryStream + Sink<Item>,
S::Ok: TryFuture<Error = S::Error>,
impl<T> Sink<T> for Drain<T>
impl<T> Sink<T> for Drain<T>
impl<Si1, Si2, Item> Sink<Item> for Fanout<Si1, Si2> where
Si1: Sink<Item>,
Item: Clone,
Si2: Sink<Item, SinkError = Si1::SinkError>,
impl<Si1, Si2, Item> Sink<Item> for Fanout<Si1, Si2> where
Si1: Sink<Item>,
Item: Clone,
Si2: Sink<Item, SinkError = Si1::SinkError>,
impl<Si, Item, E> Sink<Item> for SinkErrInto<Si, Item, E> where
Si: Sink<Item>,
Si::SinkError: Into<E>,
impl<Si, Item, E> Sink<Item> for SinkErrInto<Si, Item, E> where
Si: Sink<Item>,
Si::SinkError: Into<E>,
impl<Si, F, E, Item> Sink<Item> for SinkMapErr<Si, F> where
Si: Sink<Item>,
F: FnOnce(Si::SinkError) -> E,
impl<Si, F, E, Item> Sink<Item> for SinkMapErr<Si, F> where
Si: Sink<Item>,
F: FnOnce(Si::SinkError) -> E,
impl<Si, Item, U, Fut, F, E> Sink<U> for With<Si, Item, U, Fut, F> where
Si: Sink<Item>,
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Si::SinkError>,
impl<Si, Item, U, Fut, F, E> Sink<U> for With<Si, Item, U, Fut, F> where
Si: Sink<Item>,
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Si::SinkError>,
impl<Si, Item, U, St, F> Sink<U> for WithFlatMap<Si, Item, U, St, F> where
Si: Sink<Item>,
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Si::SinkError>>,
impl<Si, Item, U, St, F> Sink<U> for WithFlatMap<Si, Item, U, St, F> where
Si: Sink<Item>,
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Si::SinkError>>,
impl<Si: Sink<Item>, Item> Sink<Item> for Buffer<Si, Item>
impl<Si: Sink<Item>, Item> Sink<Item> for Buffer<Si, Item>
impl<S, SinkItem> Sink<SinkItem> for Compat01As03Sink<S, SinkItem> where
S: Sink01<SinkItem = SinkItem>,
impl<S, SinkItem> Sink<SinkItem> for Compat01As03Sink<S, SinkItem> where
S: Sink01<SinkItem = SinkItem>,