Skip to main content

ocpp_client/
lib.rs

1//! OCPP client (charge point side) protocol implementation.
2//!
3//! The engine (`Client<E>`, `Action`, `Transport{Sink,Stream}`) is shared by every OCPP
4//! version; `OCPP1_6Client`/`OCPP2_0_1Client` are just that engine parameterized with each
5//! version's error type. See CLAUDE.md for the broader architecture/roadmap.
6
7#![cfg_attr(not(feature = "std"), no_std)]
8
9extern crate alloc;
10
11mod action;
12mod client;
13mod envelope;
14mod error;
15mod keepalive;
16mod reconnect;
17pub mod runtime;
18mod sync;
19mod transport;
20
21#[cfg(feature = "websocket")]
22mod connect;
23
24#[cfg(feature = "ocpp_1_6")]
25pub mod ocpp_1_6;
26
27#[cfg(feature = "ocpp_2_0_1")]
28pub mod ocpp_2_0_1;
29
30#[cfg(feature = "ocpp_2_1")]
31pub mod ocpp_2_1;
32
33/// Re-exported so callers can name request/response types (e.g.
34/// `ocpp_client::ocpp_types::v16::HeartbeatRequest`) using the exact `ocpp-types` version this
35/// crate was compiled against, without needing to pin a matching version in their own
36/// `Cargo.toml` - same rationale as the `rustls` re-export below.
37pub use ocpp_types;
38
39pub use action::Action;
40pub use client::{Client, ClientConfig};
41pub use error::{ClientError, ProtocolError};
42pub use keepalive::{KeepaliveBehavior, KeepalivePolicy};
43pub use reconnect::{ReconnectBehavior, ReconnectPolicy, Reconnector};
44pub use runtime::{Elapsed, Executor, Timer};
45pub use transport::{TransportError, TransportEvent, TransportSink, TransportStream};
46
47#[cfg(feature = "tokio-runtime")]
48pub use runtime::tokio::{TokioExecutor, TokioTimer};
49
50#[cfg(feature = "websocket")]
51pub use connect::ConnectOptions;
52
53/// Re-exported so callers can build a `rustls::ClientConfig` (e.g. with a custom root CA via
54/// `ConnectOptions::tls_config`) using the exact `rustls` version this crate was compiled
55/// against, without needing to pin a matching version in their own `Cargo.toml`.
56#[cfg(feature = "websocket")]
57pub use rustls;
58
59#[cfg(feature = "websocket")]
60pub use connect::{NegotiatedClient, OcppVersion, connect, websocket_transport};
61
62#[cfg(all(feature = "websocket", feature = "ocpp_1_6"))]
63pub use connect::connect_1_6;
64
65#[cfg(all(feature = "websocket", feature = "ocpp_2_0_1"))]
66pub use connect::connect_2_0_1;
67
68#[cfg(all(feature = "websocket", feature = "ocpp_2_1"))]
69pub use connect::connect_2_1;