[−][src]Crate quicksink
Create a Sink
implementation from an initial value and a closure
returning a Future
.
This is very similar to how futures::stream::unfold
creates a Stream
implementation from a seed value and a future-returning closure.
Error behaviour
If any of the Sink
methods produce an error, the sink transitions to
a closed state. Invoking Sink::poll_ready
or Sink::start_send
on a sink in closed state will cause a panic. Invoking
Sink::poll_flush
or Sink::poll_close
after an error will have no
effect.
Examples
use async_std::io; use futures::prelude::*; use quicksink::Action; quicksink::make_sink(io::stdout(), |mut stdout, action| async move { match action { Action::Send(x) => stdout.write_all(x).await?, Action::Flush => stdout.flush().await?, Action::Close => stdout.close().await? } Ok::<_, io::Error>(stdout) });
Structs
SinkImpl |
|
Enums
Action | The command given to the closure so that it can perform appropriate action. |
Functions
make_sink | Returns a |