Trait dialectic::types::HasDual [−][src]
Each session type has a HasDual::DualSession
, the type of the corresponding client on the
other side of the channel. The sealed trait HasDual
enumerates these types, and provides the
dual of each.
💡 In general, you should prefer the Session
trait to the HasDual
trait, since
Session
also ensures that a given type is a valid session type and provides other
functionality.
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<Call<Send<String, Done>, Done>, Recv<usize, Done>, Done>, Recv<bool, Continue<0>>)>>; type Server = Loop<Choose<(Split<Send<usize, Done>, Call<Recv<String, Done>, Done>, Done>, Send<bool, Continue<0>>)>>; assert_type_eq_all!(Client, <Server as HasDual>::DualSession);
Associated Types
type DualSession: HasDual<DualSession = Self>
[src]
The dual to this session type, i.e. the session type required of the other end of the channel.
Implementors
impl HasDual for Done
[src]
type DualSession = Done
impl<Choices: Any> HasDual for Choose<Choices> where
Choices: Tuple,
Choices::AsList: EachHasDual,
<Choices::AsList as EachHasDual>::Duals: List + EachHasDual,
[src]
Choices: Tuple,
Choices::AsList: EachHasDual,
<Choices::AsList as EachHasDual>::Duals: List + EachHasDual,
type DualSession = Offer<<<Choices::AsList as EachHasDual>::Duals as List>::AsTuple>
impl<Choices: Any> HasDual for Offer<Choices> where
Choices: Tuple,
Choices::AsList: EachHasDual,
<Choices::AsList as EachHasDual>::Duals: List + EachHasDual,
[src]
Choices: Tuple,
Choices::AsList: EachHasDual,
<Choices::AsList as EachHasDual>::Duals: List + EachHasDual,
type DualSession = Choose<<<Choices::AsList as EachHasDual>::Duals as List>::AsTuple>
impl<P> HasDual for Loop<P> where
P: HasDual,
[src]
P: HasDual,
type DualSession = Loop<<P as HasDual>::DualSession>
impl<P: HasDual, Q: HasDual> HasDual for Call<P, Q>
[src]
type DualSession = Call<P::DualSession, Q::DualSession>
impl<P: HasDual, Q: HasDual, R: HasDual> HasDual for Split<P, Q, R>
[src]
type DualSession = Split<Q::DualSession, P::DualSession, R::DualSession>
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.