1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use super::sealed::IsSession;
use crate::types::*;
use std::{any::Any, marker::PhantomData};

/// Receive a message of type `T` using [`recv`](crate::Chan::recv), then continue with
/// protocol `P`.
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Recv<T, P>(pub PhantomData<T>, pub P);

impl<T: Any, P: Any> IsSession for Recv<T, P> {}

impl<T: Any, P: HasDual> HasDual for Recv<T, P> {
    type DualSession = Send<T, P::DualSession>;
}

impl<T: 'static, P: 'static> Actionable for Recv<T, P> {
    type NextAction = Self;
}

impl<T: 'static, N: Unary, P: Scoped<N>> Scoped<N> for Recv<T, P> {}

impl<N: Unary, T: 'static, P: Subst<Q, N>, Q> Subst<Q, N> for Recv<T, P> {
    type Substituted = Recv<T, P::Substituted>;
}

impl<N: Unary, T: 'static, P: Then<Q, N>, Q> Then<Q, N> for Recv<T, P> {
    type Combined = Recv<T, P::Combined>;
}

impl<N: Unary, T: 'static, P: Lift<N, Level>, Level: Unary> Lift<N, Level> for Recv<T, P> {
    type Lifted = Recv<T, P::Lifted>;
}