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 reconnect;
16pub mod runtime;
17mod sync;
18mod transport;
19
20#[cfg(feature = "websocket")]
21mod connect;
22
23#[cfg(feature = "ocpp_1_6")]
24pub mod ocpp_1_6;
25
26#[cfg(feature = "ocpp_2_0_1")]
27pub mod ocpp_2_0_1;
28
29#[cfg(feature = "ocpp_2_1")]
30pub mod ocpp_2_1;
31
32/// Re-exported so callers can name request/response types (e.g.
33/// `ocpp_client::ocpp_types::v16::HeartbeatRequest`) using the exact `ocpp-types` version this
34/// crate was compiled against, without needing to pin a matching version in their own
35/// `Cargo.toml` - same rationale as the `rustls` re-export below.
36pub use ocpp_types;
37
38pub use action::Action;
39pub use client::Client;
40pub use error::{ClientError, ProtocolError};
41pub use reconnect::{ReconnectBehavior, ReconnectPolicy, Reconnector};
42pub use runtime::{Elapsed, Executor, Timer};
43pub use transport::{TransportError, TransportEvent, TransportSink, TransportStream};
44
45#[cfg(feature = "tokio-runtime")]
46pub use runtime::tokio::{TokioExecutor, TokioTimer};
47
48#[cfg(feature = "websocket")]
49pub use connect::ConnectOptions;
50
51/// Re-exported so callers can build a `rustls::ClientConfig` (e.g. with a custom root CA via
52/// `ConnectOptions::tls_config`) using the exact `rustls` version this crate was compiled
53/// against, without needing to pin a matching version in their own `Cargo.toml`.
54#[cfg(feature = "websocket")]
55pub use rustls;
56
57#[cfg(feature = "websocket")]
58pub use connect::{NegotiatedClient, OcppVersion, connect};
59
60#[cfg(all(feature = "websocket", feature = "ocpp_1_6"))]
61pub use connect::connect_1_6;
62
63#[cfg(all(feature = "websocket", feature = "ocpp_2_0_1"))]
64pub use connect::connect_2_0_1;
65
66#[cfg(all(feature = "websocket", feature = "ocpp_2_1"))]
67pub use connect::connect_2_1;