Crate quicksink[−][src]
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.
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) });
Panics
- If any of the
Sinkmethods produce an error, the sink transitions to a failure state and none of its methods must be called afterwards or else a panic will occur. - If
Sink::poll_closehas been called, no other sink method must be called afterwards or else a panic will be caused.
Structs
| SinkImpl |
|
Enums
| Action | The command given to the closure so that it can perform appropriate action. |
Functions
| make_sink | Returns a |