Function mpstthree::functionmpst::close::close_mpst[][src]

pub fn close_mpst<R>(
    s: MeshedChannels<End, End, RoleEnd, R>
) -> Result<(), Box<dyn Error>> where
    R: Role
Expand description

Closes a MeshedChannels.

Synchronises with all partners, and fails if one of the partners has crashed.

Example

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

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

use mpstthree::functionmpst::close::close_mpst;

// Creating the binary sessions
type AtoB = End;
type AtoC = End;

// Stack
type StackA = RoleEnd;

// Name
type NameA = RoleA<RoleEnd>;

// From this point...

let (channel_ab, _) = AtoB::new();
let (channel_ac, _) = AtoC::new();

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

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

let sess = 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 _s = close_mpst(sess);