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

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

Receive a value of type T on A from C. 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_a_from_c;
use mpstthree::functionmpst::send::send_mpst_c_to_a;

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

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

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

// From this point...

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

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

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

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

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

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

let _ = send_mpst_c_to_a((), sess_c);
let _ = recv_mpst_a_from_c(sess_a).unwrap();