1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! A Rust toolkit for [OICP](https://github.com/hubject/oicp) (Open InterCharge Protocol), the
//! roaming protocol that connects Charge Point Operators and e-Mobility Providers through the
//! Hubject brokering system.
//!
//! Unlike OCPI, which is peer-to-peer, OICP is **hub-and-spoke**: every partner talks only to
//! Hubject, over mutual TLS, and Hubject calls back into the partner for the reverse direction.
//! Both halves are needed to go live, and this crate ships both.
//!
//! # What is here
//!
//! | Layer | Feature | What it gives you |
//! |---|---|---|
//! | [`types`] | *(always)* | identifiers with both ISO and DIN grammars, `Number`, `Extensions`, RFC 6901 validation |
//! | [`cpo`] | `cpo` | the CPO half of the OICP 2.3 wire model |
//! | [`emp`] | `emp` | the EMP half of the OICP 2.3 wire model |
//! | [`transport`] | `transport` | the endpoint table, page envelope and error mapping |
//! | [`client`] | `client` | an async client with mutual TLS, paginated crawls and delta pulls |
//! | [`server`] | `server` | an `axum` router per role — the Hubject-facing half |
//! | [`sync`] | `sync` | the `LastCall` delta engine, and the minimal-push planner |
//! | [`eichrecht`] | `eichrecht` | typed calibration-law data, and CDR pre-flight |
//! | [`testkit`] | `testkit` | samples and `MockHubject` — a broker to test against, offline |
//!
//! # Five properties worth knowing about
//!
//! **Energy and money are never floats.** Every `number` in every message is a [`types::Number`],
//! an exact decimal, and every sum, difference and comparison in this crate is decimal arithmetic
//! — so OICP's own rule, that `ConsumedEnergy` is the difference between `MeterValueEnd` and
//! `MeterValueStart`, holds exactly. `cargo run -p xtask -- no-floats` fails the build on an
//! `f32` or `f64` anywhere in `src/`, with one exemption it names: the JSON boundary in
//! `types::Number` itself, which is exact for every value OICP carries and reports the rest
//! through [`types::Number::json_round_trips`].
//!
//! **Identifiers are parsed, and the wire form survives.** [`types::EvseId`] and its siblings
//! understand both the ISO 15118 and DIN SPEC 91286 grammars, expose the country and operator, and
//! compare case-, separator- and `+`-insensitively — but re-serialise byte-identically. Hubject
//! matches identifiers against your TLS certificate as text; a library that normalises them breaks
//! production with status code `017`.
//!
//! **Parsing and conformance are separate questions.** A `PullEvseData` page carries thousands of
//! records from dozens of operators. One malformed field cannot make the page undecodable: the
//! value arrives, and [`types::Validate::validate`] reports it with a JSON Pointer. One malformed
//! *record* cannot cost the page either — [`client::EmpClient::crawl_evse_data`] decodes the
//! envelope first and each record on its own, so a crawl loses one charging point rather than
//! every charging point after it.
//!
//! **Nothing a peer sent is thrown away.** OICP 2.3 is edited in place, without version bumps.
//! Undocumented fields land in [`types::Extensions`] and are written back verbatim; an enum value
//! this crate has never seen keeps its text in a `Custom` variant.
//!
//! **Both directions, one trait each.** Most OICP implementations ship the client half and leave
//! Hubject's callbacks as an exercise. Here the CPO role is [`client::CpoClient`] plus
//! [`server::CpoService`]; implement the trait and your Hubject-facing surface is complete.
//!
//! # Getting started
//!
//! use oicp_kit::types::{EvseId, Validate};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Two ways of writing the same charging spot.
//! let iso: EvseId = "DE*AB7*E840*6487".parse()?;
//! let packed: EvseId = "DEAB7E8406487".parse()?;
//!
//! assert_eq!(iso, packed); // the same EVSE…
//! assert_eq!(iso.to_string(), "DE*AB7*E840*6487"); // …each written back as it arrived
//! assert_eq!(iso.operator_id(), packed.operator_id());
//! # Ok(())
//! # }
//! ```
//!
//! # Spec traceability
//!
//! Public items carry the name of the OICP 2.3 message or type they implement, so a reviewer — or
//! a partner's compliance team — can go from a Rust type to the document that defines it. Where
//! Hubject's own documents disagree with one another, [`types::ERRATA`] records the conflict, what
//! breaks, and which spelling this crate emits.
//!
//! OICP is a protocol owned and maintained by [Hubject GmbH](https://www.hubject.com/). This
//! project is not affiliated with Hubject.
/// The README's examples, compiled as doctests.
///
/// The front page of a crate is the part most people read and the part nothing checks. This makes
/// `cargo test --doc` check it: an example that stops compiling is a failing test rather than a
/// paragraph that quietly stopped being true.
// The examples reach across the whole crate, so they are checked on the feature set
// that has all of it.
;
/// The version of OICP this crate implements.
///
/// OICP 2.3 is the last version: in September 2025 Hubject committed to native OCPI support on
/// intercharge, so there is no 2.4. What does change is the 2.3 documents themselves, which
/// Hubject edits in place — which is why [`types::Extensions`] and the open enums exist.
pub const OICP_VERSION: &str = "2.3";