oicp-kit

Rust · OICP 2.3 · Hubject

OICP for Rust,
both directions

A spec-exact wire model for OICP 2.3, a mutual-TLS client, an axum server for the half Hubject calls, an EVSE delta-sync engine, CDR pre-flight, and a brokering system in a process so you can integrate before you onboard. One crate, behind cargo features.

cargo add oicp-kit

Three properties that decide quality

Energy and money are never floats

Every OICP number is an exact decimal. No public field of any wire type is an f32 or f64, the sync engine has none either, and a repository check enforces it in CI.

OICP defines ConsumedEnergy as MeterValueEnd − MeterValueStart. In f64, 10.1 − 0.1 is 10.000000000000002.

Numbers and money →

Identifiers are never rewritten

Every OICP identifier accepts two grammars — ISO 15118 and DIN SPEC 91286. This crate parses both, exposes the country and operator, compares them semantically, and writes back the exact text that arrived.

Hubject matches the identifier in your URL against your TLS certificate as text. A library that normalises DE*ABC to DEABC earns a 017 on every request.

Identifiers →

Parsing and conformance are separate

One operator's malformed HotlinePhoneNumber cannot make a page of two thousand EVSE records undecodable. The value arrives; validation reports it with an RFC 6901 JSON Pointer.

Parse permissively, validate explicitly, construct strictly.

The rule →

A brokering system, in a process

Testing against the real thing needs a signed contract, certificates from Hubject's CA, and access to their QA environment — weeks before the first request. And the failures that cost time are sequences, not single messages.

MockHubject routes the way the real broker does, tracks sessions, and answers with the specification's own status codes. Offline, in a unit test.

Testkit →
let mut hubject = MockHubject::new();
hubject.register_emp(MockEmp::permissive("DE-DCB".parse()?));
hubject.push_evse_data(&samples::evse_data_record("DE*ABC*E1").into())?;

// A driver swipes a card. The broker routes on the contract, exactly as the real one does.
let response = hubject.authorize_start(&samples::authorize_start_request("DE*ABC*E1"));
let session = response.session_id.clone().unwrap();

// A CDR for a session the broker opened settles…
hubject.submit_cdr(&samples::charge_detail_record("DE*ABC*E1", session))?;

// …and one for a session it did not is refused, with the specification's own code.
let invented = samples::charge_detail_record("DE*ABC*E1", samples::session_id());
assert_eq!(*hubject.submit_cdr(&invented).unwrap_err().code(), Code::SessionIsInvalid);

What is in the box

Checked against the specification, not against intent

The vendored Hubject documents are pinned to the commits this crate was written against, and repository automation compares the crate with them on every push.

How it is verified