mpstthree 0.1.17

A library implementing Multiparty Session Types for 2 or more participants
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! This module contains the functions for closing
//! binary sessions.

use crate::binary::struct_trait::{end::End, end::Signal};

use std::error::Error;

/// Closes a session. Synchronises with the partner, and
/// fails if the partner has crashed.
pub fn close(s: End) -> Result<(), Box<dyn Error>> {
    s.sender.send(Signal::Stop)?;
    match s.receiver.recv()? {
        Signal::Stop => {}
        err => panic!("Unexpected label, expected Signal::Stop, got {:?}", err),
    }
    drop(s);
    Ok(())
}