Termination
Provider Rule: Terminate
fn terminate<C>() -> PartialSession<C, End>
Cmust be an empty linear context that implementsEmptyContext. e.g:HList![]HList![Empty]HList![Empty, Empty, ...]
Example:
let p: Session<End> = terminate();
Client Rule: Wait
fn wait<N, C1, C2, A>(
n: N,
cont: PartialSession<C2, A>
) -> PartialSession<C1, A>
C1is in the formHList[…, N: End, …].C2is in the formHList[…, N: Empty, …]with the remaining elements inC1unchanged.
Example:
let p: Session<ReceiveChannel<End, End>> =
receive_channel(move |c| wait(c, terminate()));
Client Rule: Wait All
macro wait_all! <C1, C2, B> (
[$channels],
$cont: PartialSession<C2, B>
) -> PartialSession<C1, B>
- Expands
wait_all!([c1, c2, …], cont)towait(c1, wait(c2, … cont).
Example:
let p: Session<ReceiveChannel<End, ReceiveChannel<End, End>>> =
receive_channel(move |c1| {
receive_channel(move |c2| wait_all!([c1, c2], terminate()))
});