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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//! The types every OICP message is built from: identifiers, numbers, text, validation.
//!
//! This module is always compiled — the wire models, the client, the server and the sync engine
//! all speak it.
//!
//! # Identifiers are parsed but never rewritten
//!
//! Every OICP identifier accepts **two** grammars, ISO 15118 and DIN SPEC 91286, and Hubject
//! compares the one in your URL path against your TLS client certificate **as text**. So
//! [`EvseId`] and its siblings parse the grammar, expose the country and operator, and compare
//! case- and separator-insensitively — but re-serialise byte-identically. A library that
//! normalises `DE*ABC` to `DEABC` earns [`Code::UnauthorizedAccess`] on every request.
//!
//! ```
//! use oicp_kit::types::EvseId;
//!
//! let a: EvseId = "DE*AB7*E840*6487".parse()?;
//! let b: EvseId = "DEAB7E8406487".parse()?;
//!
//! assert_eq!(a, b); // the same charging spot
//! assert_eq!(a.to_string(), "DE*AB7*E840*6487"); // …written back as it arrived
//! assert_eq!(a.operator_id(), b.operator_id()); // …and Hubject's routing rule, for free
//! # Ok::<(), oicp_kit::types::IdError>(())
//! ```
//!
//! # Energy and money are never floats
//!
//! Every OICP `number` is a [`Number`], an exact decimal. OICP *defines* `ConsumedEnergy` as
//! `MeterValueEnd - MeterValueStart`, and in `f64` that identity does not hold: `10.1 - 0.1` is
//! `10.000000000000002`. `cargo run -p xtask -- no-floats` keeps it that way.
//!
//! # Parse permissively, validate explicitly, construct strictly
//!
//! A `PullEvseData` page carries thousands of records from dozens of operators. One operator's
//! malformed `HotlinePhoneNumber` must not make the page undecodable — a roaming platform that
//! drops a page because one CPO is sloppy is worse than one that accepts it and reports the
//! problem. So:
//!
//! * `Deserialize` accepts what the peer sent, as long as it is well-typed JSON.
//! * [`Validate::validate`] reports *every* violation, each with a JSON Pointer
//! ([RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901)) using OICP's **wire** field names
//! — `/EvseID`, `/Address/PostalCode` — not the snake-case Rust ones.
//! * Every builder's `build()` returns `Result<T, Violations>`, so an object this crate emits is
//! conformant by construction. `build_unchecked()` exists, and says what it is.
//!
//! ```
//! use oicp_kit::types::Address;
//!
//! // Constructing strictly: OICP 2.2 and 2.3 allow only alpha-3 country codes.
//! let err = Address::builder()
//! .country("DE")
//! .city("Berlin")
//! .street("EUREF CAMPUS")
//! .postal_code("10829")
//! .house_num("22")
//! .build()
//! .unwrap_err();
//! assert_eq!(err.as_slice()[0].pointer, "/Country");
//! ```
//!
//! # Open enums by default
//!
//! OICP 2.3 writes every enumerated type as a closed list, but Hubject edits the 2.3 documents
//! **in place** without a version bump, and the lists grow. Discarding a value this crate has not
//! seen would make a forwarding hub lossy — so almost every enum here keeps it in a `Custom`
//! variant, re-serialises it byte-identically, and still reports it through [`Validate`].
//!
//! The exceptions are the two where an unknown value has no safe reading: [`ActionType`], where
//! guessing could delete an operator's fleet from the roaming network, and
//! `AuthorizationStatus`, where neither "probably authorized" nor "probably not" is a decision a
//! library should make.
//!
//! Undocumented *fields* land in [`Extensions`] and are written back verbatim, for the same reason.
//!
//! # Where Hubject's own documents disagree
//!
//! OICP 2.3 is published as four documents — two leading AsciiDoc specifications and two OpenAPI
//! schema sets — and they contradict each other in six places, each of which means partners
//! implementing from different documents produce payloads that do not interoperate.
//!
//! [`ERRATA`] records every one with what breaks and which spelling this crate emits: the leading
//! document's, while accepting both on input. `cargo run -p xtask -- errata` checks that each is
//! still a contradiction upstream, so an erratum Hubject fixes fails CI rather than lingering.
//!
//! ```
//! use oicp_kit::types::ERRATA;
//!
//! for erratum in ERRATA {
//! println!("{}: {} — {}", erratum.id, erratum.field, erratum.resolution);
//! }
//! ```
// Opening times are a property of a charging point, so this is only reachable through
// `EvseDataRecord` and `PullEvseDataRecord`.
pub use Acknowledgement;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Extensions;
pub use ;
pub use ;
pub use ;
pub use Number;
pub use UnknownVariant;
pub use ;
pub use ;
pub use ;
pub use ;
pub use strict_builder;
pub use is_open_at as opening_at;
// The wire models reach the macro through this alias; inside `types` it is imported directly.
pub use validate_fields;