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

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

Receive a value of type T on B 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::b::RoleB;
use mpstthree::role::c::RoleC;
use mpstthree::role::end::RoleEnd;

use mpstthree::functionmpst::recv::recv_mpst_b_from_c;
use mpstthree::functionmpst::send::send_mpst_c_to_b;

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

// Stack
type StackB = RoleC<RoleEnd>;
type StackC = RoleB<RoleEnd>;

// Name
type NameB = RoleB<RoleEnd>;
type NameC = RoleC<RoleEnd>;

// From this point...

let (channel_ba, _) = End::new();
let (channel_ca, _) = End::new();
let (channel_bc, channel_cb) = BtoC::new();

let (role_b, _) = StackB::new();
let (role_c, _) = StackC::new();

let (name_b, _) = NameB::new();
let (name_c, _) = NameC::new();

let sess_b = MeshedChannels {
    session1: channel_ba,
    session2: channel_bc,
    stack: role_b,
    name: name_b,
};

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_b((), sess_c);
let _ = recv_mpst_b_from_c(sess_b).unwrap();