dialectic (noun): The process of arriving at the truth by stating a thesis, developing a contradictory antithesis, and combining them into a coherent synthesis.
dialectic (crate): Transport-polymorphic session types for asynchronous Rust.
When two concurrent processes communicate, it's good to give their messages types, which ensure every message is of an expected form.
This crate provides a generic wrapper around almost any type of asynchronous channel that adds compile-time guarantees that a specified session protocol will not be violated by any code using the channel. Such a wrapped channel:
async
/.await
to allow integration with Rust's powerful async
ecosystem;Together, these make Dialectic ideal for writing networked services that need to ensure high levels of availability and complex protocol correctness properties in the real world, where protocols might be violated and connections might be dropped.
Dialectic supports a number of async runtimes and backends out-of-the-box, if you don't want to or don't need to write your own:
dialectic-tokio-mpsc
crate supports using Dialectic to communicate between
tasks using Tokio's mpsc
queues.dialectic-tokio-serde
crate supports using Dialectic to communicate over any AsyncRead
/AsyncWrite
transport layer encoded using any Tokio codec
. A couple of Serde formats are already implemented, but it is easy to implement your own:
dialectic-tokio-serde-bincode
backend using bincode
for serializationdialectic-tokio-serde-json
backend using serde_json
for serializationThese crates also serve as good references for writing your own backends.
Session!
macro for specifying session types, and
continue on to look at the types
module and the documentation for Chan
.Transmit
and Receive
traits from the backend
module.