rustflexstack/lib.rs
1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2024 Fundació Privada Internet i Innovació Digital a Catalunya (i2CAT)
3
4//! # rustflexstack
5//!
6//! ETSI C-ITS GeoNetworking (EN 302 636-4-1) + BTP (EN 302 636-5-1) protocol
7//! stack implemented in Rust.
8//!
9//! ## Architecture
10//!
11//! The stack is built around an actor model where each layer runs in its own
12//! background thread and communicates via [`std::sync::mpsc`] channels. The
13//! caller interacts with the routers through lightweight handle types that wrap
14//! a [`std::sync::mpsc::Sender`].
15//!
16//! ## Typical usage
17//!
18//! ```no_run
19//! use rustflexstack::link_layer::raw_link_layer::RawLinkLayer;
20//! use rustflexstack::geonet::router::Router;
21//! use rustflexstack::geonet::mib::MIB;
22//! use rustflexstack::btp::router::BTPRouter;
23//! use rustflexstack::btp::service_access_point::BTPDataRequest;
24//! use rustflexstack::geonet::service_access_point::{
25//! GNDataRequest, HeaderType, TopoBroadcastHST, TrafficClass,
26//! };
27//! use std::sync::mpsc;
28//!
29//! let (ll_to_gn_tx, ll_to_gn_rx) = mpsc::channel();
30//! let (gn_to_ll_tx, gn_to_ll_rx) = mpsc::channel();
31//! let (gn_to_btp_tx, gn_to_btp_rx) = mpsc::channel();
32//! let (btp_to_gn_tx, btp_to_gn_rx) = mpsc::channel();
33//!
34//! let mib = MIB::new();
35//! let ll = RawLinkLayer::new(ll_to_gn_tx, gn_to_ll_rx, "eth0").unwrap();
36//! let gn_handle = Router::spawn(
37//! mib.clone(), ll.sender(),
38//! gn_to_ll_tx, ll_to_gn_rx,
39//! gn_to_btp_tx, btp_to_gn_rx,
40//! );
41//! let btp_handle = BTPRouter::spawn(mib.clone(), gn_handle.clone(), gn_to_btp_rx);
42//! ```
43
44pub mod btp;
45pub mod facilities;
46pub mod geonet;
47pub mod link_layer;