#sink #future #async


Create a Sink from some value and a closure returning a Future

3 releases

0.1.2 Apr 7, 2020
0.1.1 Jan 7, 2020
0.1.0 Dec 10, 2019

#1327 in Asynchronous

Download history 29087/week @ 2024-01-06 34203/week @ 2024-01-13 34847/week @ 2024-01-20 33277/week @ 2024-01-27 33818/week @ 2024-02-03 36349/week @ 2024-02-10 41975/week @ 2024-02-17 38032/week @ 2024-02-24 32326/week @ 2024-03-02 35471/week @ 2024-03-09 36849/week @ 2024-03-16 36301/week @ 2024-03-23 47641/week @ 2024-03-30 48526/week @ 2024-04-06 40823/week @ 2024-04-13 33509/week @ 2024-04-20

173,953 downloads per month
Used in 210 crates (9 directly)

Apache-2.0 OR MIT

260 lines


Allows creating an implementation of the Sink trait from an initial value and a closure returning a Future.


This project is licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


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.


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)


  • If any of the Sink methods 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_close has been called, no other sink method must be called afterwards or else a panic will be caused.