Expand description
§ecr17-protocol
A pure-Rust implementation of the Italian ECR17 payment protocol used by Nexi Group POS terminals over a local LAN connection.
The crate is layered so the protocol logic is trivially testable and free of I/O
(modules are added incrementally per docs/PLAN.md):
lrc— LRC checksum andLrcModeframing selectorcodec— STX/ETX/LRC framing (encode/decode)types— request/result/enum data model (serde)protocol— message builders (one per ECR17 command)response— response parsersretry— money-safety retry policy (a financial command is never blindly replayed)session— ACK/NAK, retransmit, timeout orchestration over aTransportclient— the asyncEcr17ClientAPI
I/O lives behind the async Transport trait; the real tokio TCP transport is
available under the tokio-transport feature.
💰 Money-critical: this drives a terminal that charges real cards. Financial
commands are never blindly re-sent after a reconnect — recover a lost response via
send_last_result() (spec command G).
Protocol reference (public): https://developer.nexigroup.com/traditionalpos/en-EU/docs/
Re-exports§
pub use client::Ecr17Client;pub use codec::DecodedPacket;pub use codec::PacketCodec;pub use codec::PacketType;pub use error::Ecr17Error;pub use error::Result;pub use lrc::LrcMode;pub use retry::should_retry_after_reconnect;pub use session::Ecr17Session;pub use session::SessionConfig;pub use transport::FakeTransport;pub use transport::Transport;pub use types::*;
Modules§
- client
Ecr17Client— the high-level async API: builds requests, drives theEcr17Session, parses/maps responses to the typedcrate::typesresults, and applies the money-safe auto-reconnect policy. Port of the reference C++HybridEcr17Client.- codec
- ECR17 packet framing: encode/decode
STX payload ETX LRCapplication frames,SOH message EOTprogress updates (no LRC), andACK/NAKcontrol frames. - error
- Crate error type.
- lrc
- LRC checksum and the
LrcModeframing selector. - protocol
- ECR17 application-message builders — the bytes that go between
STXandETX. - response
- Parsers for ECR17 terminal response application messages.
- retry
- Money-safety retry policy.
- session
Ecr17Session— drives one ECR17 request/response exchange over aTransport.- transport
- The async
Transportabstraction and an in-memoryFakeTransportfor tests. - types
- Request/result/config data model (serde), mirroring the reference
types/client.tsfield-for-field. Enums serialize to the same JSON string unions as the TS API and struct fields usecamelCase, so the model maps cleanly onto the Tauri IPC. Absent optional fields deserialize toNone; aNoneserializes as JSONnull(the TS side treatsnull/absent equivalently for these optional fields).