codetics-ocpp21 0.1.0

Codetics OCPP: OCPP 2.1 message types with validation and typed dispatch, including SEND messages
Documentation
  • Coverage
  • 33.5%
    936 out of 2794 items documented0 out of 543 items with examples
  • Size
  • Source code size: 813.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 25.3 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kevinvavelin

codetics-ocpp21

Every OCPP 2.1 (Edition 2) message as plain Rust types, including the new functional areas (bidirectional power transfer and DER control, dynamic and priority charging profiles, local cost calculation with tariffs, battery swapping, periodic event streams) and the unconfirmed SEND message type.

  • serde mappings matching the message definitions; customData extensions are preserved;
  • Validate implementations for length, range and cardinality constraints, with violations mapped to OCPP-J error codes;
  • Action with message direction, and typed dispatch: StationCall, CsmsCall and StationSend.
use codetics_ocpp21::{Action, Direction, StationSend};

assert_eq!(Action::BatterySwap.direction(), Direction::StationToCsms);
assert!(Action::NotifyPeriodicEventStream.is_send());

let p = r#"{"id":1,"pending":0,"basetime":"2025-01-01T00:00:00Z","data":[{"t":0,"v":"230.4"}]}"#;
let StationSend::NotifyPeriodicEventStream(stream) = StationSend::decode("NotifyPeriodicEventStream", p).unwrap();
assert_eq!(stream.data.len(), 1);

Part of Codetics OCPP

This crate belongs to Codetics OCPP, a complete OCPP 1.6J / 2.0.1 / 2.1 implementation in Rust written by Kevin Vavelin (Codetics). It can be used as is; contributions are welcome.

License and credit

Licensed under the Apache License, Version 2.0.

Copyright 2026 Kevin Vavelin, Codetics. Any redistribution of this crate or of a work derived from it (including forks and products embedding it) must keep the copyright notice and include the NOTICE file crediting Kevin Vavelin / Codetics as the origin of the work.