codetics-ocpp-ws 0.1.0

Codetics OCPP: dependency-light RFC 6455 WebSocket with RFC 7692 permessage-deflate, tuned for many long-lived OCPP connections
Documentation
  • Coverage
  • 38.53%
    42 out of 109 items documented0 out of 45 items with examples
  • Size
  • Source code size: 72.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 885.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kevinvavelin

codetics-ocpp-ws

A small WebSocket implementation for OCPP-J, written for servers holding tens of thousands of long-lived connections:

  • RFC 6455 framing, fragmentation, control frames and close handshake;
  • RFC 7692 permessage-deflate, which OCPP 2.0.1 and 2.1 require from a CSMS, with a memory profile suited to idle connections (pooled compressors, lazily allocated decompressors);
  • a cancel-safe reader (WsReader::recv) and a separate writer, so one task can multiplex reads, timers and commands;
  • a minimal client (client::connect / client::handshake) for simulators and tests.

The HTTP upgrade is left to your HTTP server (hyper, axum, …): wrap the upgraded stream with server().

use codetics_ocpp_ws::{Message, WsConfig, close_code};

async fn session<S: tokio::io::AsyncRead + tokio::io::AsyncWrite>(upgraded: S) {
    let (mut reader, mut writer) = codetics_ocpp_ws::server(upgraded, WsConfig::default(), None);
    while let Ok(Some(msg)) = reader.recv().await {
        match msg {
            Message::Text(text) => writer.send_text(&text).await.unwrap(),
            Message::Ping(data) => writer.send_pong(&data).await.unwrap(),
            Message::Close(_) => {
                let _ = writer.send_close(close_code::NORMAL, "").await;
                break;
            }
            _ => {}
        }
    }
}

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.