mpstthree/transport/tcp/offer.rs
1//! This module contains the macros for
2//! receiving a choice
3//! for a TCP connection.
4//!
5//! *This module is available only if MultiCrusty is built with
6//! the `"transport"` feature or the `"transport_tcp"` feature.*
7
8/// Offer a choice between many different sessions wrapped
9/// in an `enum`.
10///
11/// *This macro is available only if MultiCrusty is built with
12/// the `"transport"` feature or the `"transport_tcp"` feature.*
13#[macro_export]
14#[cfg_attr(
15 doc_cfg,
16 doc(cfg(any(feature = "transport", feature = "transport_tcp")))
17)]
18macro_rules! offer_tcp {
19 ($session: expr, { $( $pat: pat => $result: expr , )+ }) => {
20 (move || -> Result<_, _> {
21 let ((data, cont), s) = mpstthree::binary::recv::recv($session)?;
22 mpstthree::binary::cancel::cancel(s);
23 mpstthree::binary::cancel::cancel(data);
24
25 match cont {
26 $(
27 $pat => $result,
28 )+
29 _ => panic!("Unexpected payload") ,
30 }
31 })()
32 };
33}