jonhoo / async-bincode

Asynchronous access to a bincode-encoded item stream.
Apache License 2.0
67 stars 9 forks source link

Using the `Sink` for writing in async? #14

Closed swwu closed 1 year ago

swwu commented 1 year ago

I noticed this library exposes the futures_sink::Sink trait instead of the futures::sink::Sink trait. Unlike the latter, the former seems to not support futures::sink::SinkExt, which provides actual async methods for dumping things in, and there doesn't seem to be an equivalent convenience trait.

Is there currently a supported way to write to these in async contexts, by awaiting on some future, without directly interacting with the poll_ interface (and therefore having to manually manage polling/wakeups)?

jonhoo commented 1 year ago

futures::Sink is a re-export of futures_sink::Sink, so they are exactly the same :)

https://github.com/rust-lang/futures-rs/blob/89c06f5e89b8499102a198736ccc859949e049a3/futures/src/lib.rs#L115

As a result, both also support SinkExt.