Hi, I’d like to present desync, one of my Rust projects. I released version 0.2.0 last night, which adds some useful features for handling streams. I’ve been using this library quite a lot in my own projects and I think it provides a useful and at least semi-novel approach to writing asynchronous code.
desync provides a single new type,
Desync<T>, which turns a synchronous type into an asynchronous one, via two API calls.
sync performs an operation and waits for it to complete, and
async starts an operation in the background. Operations are always performed in the order that they are queued.
This API might be quite small, but it can replace a lot of other asynchronous constructs:
sync alone is an alternative to mutexes, and with
async it’s possible to avoid manually managing threads and dealing with scheduling and ordering issues.
v0.2.0 adds some new features to support the futures library. The
pipe_in functions make it possible to schedule operations on a
Desync object when data becomes available on a
Stream. This is analogous to UNIX pipes, and provides a way to asynchronously send data to an object or implement a message-passing system.
Docs are here: https://docs.rs/desync/
Repo here: https://github.com/logicalshift/desync/
Blog post with some more info here: https://logicalshift.io/articles/rust-tools/desync.html