#async #futures #sink

archived quicksink

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

#8 in #sink

Download history 23668/week @ 2022-12-05 23187/week @ 2022-12-12 20494/week @ 2022-12-19 12275/week @ 2022-12-26 19132/week @ 2023-01-02 21877/week @ 2023-01-09 24248/week @ 2023-01-16 23376/week @ 2023-01-23 23431/week @ 2023-01-30 23609/week @ 2023-02-06 25205/week @ 2023-02-13 25127/week @ 2023-02-20 28625/week @ 2023-02-27 27383/week @ 2023-03-06 31067/week @ 2023-03-13 33748/week @ 2023-03-20

123,053 downloads per month
Used in 140 crates (10 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.