[][src]Trait dialectic::types::Session

pub trait Session: Sized + IsSession {
    type Dual: Session<Dual = Self>;
}

A session type describes the sequence of operations performed by one end of a bidirectional Chan.

Each session type has a Session::Dual, the type of the corresponding client on the other side of the channel. The sealed trait Session enumerates these types, and provides the dual of each.

Examples

Here we define a Client and Server session type, which are duals of each other. This example illustrates every construct in the language of session types.

use dialectic::types::*;

type Client = Loop<Offer<(Split<Send<String, Done>, Recv<usize, Done>>, Recv<bool, Continue>)>>;
type Server = Loop<Choose<(Split<Send<usize, Done>, Recv<String, Done>>, Send<bool, Continue>)>>;

assert_type_eq_all!(Client, <Server as Session>::Dual);

Associated Types

type Dual: Session<Dual = Self>[src]

The dual to this session type, i.e. the session type required of the other end of the channel.

Loading content...

Implementors

impl Session for Done[src]

type Dual = Done

impl<Choices: Any> Session for Choose<Choices> where
    Choices: Tuple,
    Choices::AsList: EachSession,
    <Choices::AsList as EachSession>::Dual: List + EachSession
[src]

type Dual = Offer<<<Choices::AsList as EachSession>::Dual as List>::AsTuple>

impl<Choices: Any> Session for Offer<Choices> where
    Choices: Tuple,
    Choices::AsList: EachSession,
    <Choices::AsList as EachSession>::Dual: List + EachSession
[src]

type Dual = Choose<<<Choices::AsList as EachSession>::Dual as List>::AsTuple>

impl<N: Unary + Any> Session for Break<N>[src]

All Breaks are valid session types.

type Dual = Break<N>

Break is self-dual.

impl<N: Unary + Any> Session for Continue<N>[src]

type Dual = Continue<N>

impl<P: Session> Session for Loop<P>[src]

type Dual = Loop<P::Dual>

impl<P: Session, Q: Session> Session for Seq<P, Q>[src]

type Dual = Seq<P::Dual, Q::Dual>

impl<P: Session, Q: Session> Session for Split<P, Q>[src]

type Dual = Split<Q::Dual, P::Dual>

Note how the dual flips the position of P and Q, because P::Dual is a receiving session, and therefore belongs on the right of the split, and Q::Dual is a sending session, and therefore belongs on the left of the split.

impl<T: Any, P: Session> Session for Recv<T, P>[src]

type Dual = Send<T, P::Dual>

impl<T: Any, P: Session> Session for Send<T, P>[src]

type Dual = Recv<T, P::Dual>

Loading content...