ocpp-kit

Documentation

ocpp-kit implements the Open Charge Point Protocol over JSON/WebSocket — OCPP 1.6J, 2.0.1 and 2.1 — for charging stations, CSMS backends and local controllers.

It is five layers. Each is useful on its own, and you compile only what you enable: with default features there is no async runtime, no TLS and no domain logic in your binary.

LayerModuleWhat it gives youno_std
0v1_6 · v2_0_1 · v2_1Typed, validated payloads for all 39 / 64 / 91 actions✅ alloc
1rpcOCPP-J framing with version-exact error codes, plus JWS signed messages✅ alloc
2engineA sans-I/O protocol state machine✅ alloc
3transportTokio and rustls, with an RFC 6455 WebSocket and RFC 7692 compression–
4station · csmsOpt-in domain building blockspartial
—standardThe catalogues that live outside the schemas✅ alloc
—meteringSigned meter values: the record a customer may be billed for✅ alloc

Where to start

Design commitments

Spec first. Where an idiom and the specification disagree, the specification wins. NotifyPeriodicEventStream has no response type, so none is invented; 1.6J prints OccurenceConstraintViolation with one r, so that is what goes on the wire there.

Types make invalid states unrepresentable; validation catches the rest. Every schema enumeration is a Rust enum. Every constraint the type system cannot express — maxLength, minItems, ranges — is checked by a generated Validate impl whose output maps onto the OCPP error codes.

Sans-I/O by construction. The protocol state machine consumes events and produces effects. It never touches a socket or a clock — the driver passes it the current instant, so no deadline can be armed against a stale one.

A rule the API can express wrongly will be expressed wrongly. A SEND that cannot be awaited is a trait bound, not a paragraph; an unconstrained stretch of a composite schedule is an Option, not a convention; and where an option is unsafe and silent — accepting an unsigned frame, authenticating nobody — it is never the default.

Boring dependencies. serde, serde_json and jiff by default; tokio and rustls when you ask for a transport.