Function mpstthree::functionmpst::recv::recv_mpst_c_from_a[][src]

pub fn recv_mpst_c_from_a<T, S1, S2, R>(
    s: MeshedChannels<Recv<T, S1>, S2, RoleA<R>, RoleC<RoleEnd>>
) -> Result<(T, MeshedChannels<S1, S2, R, RoleC<RoleEnd>>), Box<dyn Error>> where
    T: Send,
    S1: Session,
    S2: Session,
    R: Role
Expand description

Receive a value of type T on C from A. Can fail. Returns either a pair of the received value and the continuation of the MeshedChannels<S1, S2, R, N> or an error.

Example

use mpstthree::binary::struct_trait::{end::End, recv::Recv, session::Session};
use mpstthree::meshedchannels::MeshedChannels;
use mpstthree::role::Role;

use mpstthree::role::a::RoleA;
use mpstthree::role::c::RoleC;
use mpstthree::role::end::RoleEnd;

use mpstthree::functionmpst::recv::recv_mpst_c_from_a;
use mpstthree::functionmpst::send::send_mpst_a_to_c;

// Creating the binary sessions
type CtoA = Recv<(), End>;

// Stack
type StackC = RoleA<RoleEnd>;
type StackA = RoleC<RoleEnd>;

// Name
type NameC = RoleC<RoleEnd>;
type NameA = RoleA<RoleEnd>;

// From this point...

let (channel_ca, channel_ac) = CtoA::new();
let (channel_cb, _) = End::new();
let (channel_ab, _) = End::new();

let (role_c, _) = StackC::new();
let (role_a, _) = StackA::new();

let (name_c, _) = NameC::new();
let (name_a, _) = NameA::new();

let sess_c = MeshedChannels {
    session1: channel_ca,
    session2: channel_cb,
    stack: role_c,
    name: name_c,
};

let sess_a = MeshedChannels {
    session1: channel_ab,
    session2: channel_ac,
    stack: role_a,
    name: name_a,
};

// ...to this point, should not be written in general. Please look at the *fork* function.

let _ = send_mpst_a_to_c((), sess_a);
let _ = recv_mpst_c_from_a(sess_c).unwrap();