pub trait HasDual:
IsSession
+ Sized
+ 'static {
type DualSession: HasDual<DualSession = Self>;
}
Expand description
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);
Required Associated Typesยง
Sourcetype DualSession: HasDual<DualSession = Self>
type DualSession: HasDual<DualSession = Self>
The dual to this session type, i.e. the session type required of the other end of the channel.
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.