e2e_protection/
lib.rs

1//! e2e-protection (v0.4.0)
2//!
3//! Profile-first E2E toolkit with a tiny session layer.
4//! - Core: `E2eProfile`, `E2eSession`, `CounterPolicy`
5//! - Feature `autosar`: provides P11, P22, P44, P7, P4m, P7m
6//!
7//! See each profile module’s docs for wire details.
8//!
9//! ```
10//! use e2e_protection::{E2eSession, CounterPolicy, E2eProfile};
11//! #[cfg(feature="autosar")]
12//! use e2e_protection::profiles::autosar::profile11::{P11, P11DataIdMode};
13//!
14//! #[cfg(feature="autosar")]
15//! # fn main() -> Result<(), e2e_protection::E2eError> {
16//! let mut tx = E2eSession::new(
17//!     P11 { mode: P11DataIdMode::Both { data_id: 0x0042 } },
18//!     CounterPolicy::Rollover { bits: 4, step: 1 },
19//! );
20//! let frame = tx.wrap(&[0x12, 0x34])?;
21//!
22//! let mut rx = E2eSession::new(
23//!     P11 { mode: P11DataIdMode::Both { data_id: 0x0042 } },
24//!     CounterPolicy::Rollover { bits: 4, step: 1 },
25//! );
26//! let pl = rx.unwrap(&frame)?;
27//! assert_eq!(pl, &[0x12, 0x34]);
28//! # Ok(()) }
29//! #[cfg(not(feature="autosar"))]
30//! # fn main() {}
31//! ```
32
33mod e2e;
34pub use e2e::{CheckInfo, CounterPolicy, E2eError, E2eProfile, E2eSession};
35
36pub mod profiles;