ecr17_protocol/lib.rs
1//! # ecr17-protocol
2//!
3//! A pure-Rust implementation of the Italian **ECR17** payment protocol used by
4//! **Nexi Group** POS terminals over a local LAN connection.
5//!
6//! The crate is layered so the protocol logic is trivially testable and free of I/O
7//! (modules are added incrementally per `docs/PLAN.md`):
8//!
9//! - `lrc` — LRC checksum and `LrcMode` framing selector
10//! - `codec` — STX/ETX/LRC framing (encode/decode)
11//! - `types` — request/result/enum data model (serde)
12//! - `protocol` — message builders (one per ECR17 command)
13//! - `response` — response parsers
14//! - `retry` — money-safety retry policy (a financial command is never blindly replayed)
15//! - `session` — ACK/NAK, retransmit, timeout orchestration over a `Transport`
16//! - `client` — the async `Ecr17Client` API
17//!
18//! I/O lives behind the async `Transport` trait; the real tokio TCP transport is
19//! available under the `tokio-transport` feature.
20//!
21//! 💰 **Money-critical:** this drives a terminal that charges real cards. Financial
22//! commands are never blindly re-sent after a reconnect — recover a lost response via
23//! `send_last_result()` (spec command `G`).
24//!
25//! > Protocol reference (public): <https://developer.nexigroup.com/traditionalpos/en-EU/docs/>
26
27#![forbid(unsafe_code)]
28#![warn(missing_debug_implementations)]
29
30// Layers are added incrementally per the implementation plan (docs/PLAN.md).
31pub mod client;
32pub mod codec;
33pub mod error;
34pub mod lrc;
35pub mod protocol;
36pub mod response;
37pub mod retry;
38pub mod session;
39pub mod transport;
40pub mod types;
41
42pub use client::Ecr17Client;
43pub use codec::{DecodedPacket, PacketCodec, PacketType};
44pub use error::{Ecr17Error, Result};
45pub use lrc::LrcMode;
46pub use retry::should_retry_after_reconnect;
47pub use session::{Ecr17Session, SessionConfig};
48pub use transport::{FakeTransport, Transport};
49pub use types::*;