Crate async_session_types
source · [−]Modules
Multiplexing multiple protocols over a single channel and dispatching to session handler instances.
Macros
This macro is convenient for server-like protocols of the form:
The repr_bound
macro creates a type alias that can be used as bound for the generic
wire type, instead of listing all messages used by the protocol.
The repr_impl
macro creates Repr
implementations for a type used on the wire,
for each protocol message type enumerated in the call.
Structs
A session typed channel. P
is the protocol and E
is the environment,
containing potential recursion targets. R
is the representation of
messages, which could be DynMessage
, or perhaps something we know
statically how to turn into JSON or bytes.
Active choice between P
and Q
End of communication session (epsilon)
Passive choice (offer) between P
and Q
Enter a recursive environment.
Receive T
, then resume with protocol P
.
Peano numbers: Increment
Send T
, then resume with protocol P
.
Recurse. N indicates how many layers of the recursive environment we recurse out of.
Peano numbers: Zero
Enums
Indicate whether the left or right choice was chosen in an Offer
.
Traits
The HasDual trait defines the dual relationship between protocols.
Indicate that a protocol will receive a message, and specify what type it is, so we can decide in an offer which arm we got a message for.
Indicate that a protocol will send a message.
Define for the wire representation, so that the raw messages can be lifted into it, and later the representation can be cast back into the expected types.
Functions
Create a pair of server and client channels for a given protocol P
.
Similar to session_channel
; create a typed channel for a protocol P
,
but instead of creating a channel for its dual, return the raw sender
and receiver that can be used to communicate with the channel created.
Type Definitions
We can use a dynamic boxed message to pass messages, and represent all messages in a protocol as individual structs. However if we want to send them over a network connection we will need to serialise to some wire format, and at that point we have to use tagging, so we can recognise what type to deserialise into.