ocpp_client/action.rs
1use serde::Serialize;
2use serde::de::DeserializeOwned;
3
4/// One OCPP action: its wire name plus its request/response types.
5///
6/// Shared across every OCPP version and open to consumers - implement this for your own
7/// marker type to send/register a custom (non-standard) action, or one wrapping vendor
8/// fields via `#[serde(flatten)]`, through the exact same `Client::call`/`Client::on` used
9/// for the built-in actions.
10pub trait Action: Send + Sync + 'static {
11 const NAME: &'static str;
12 type Request: Serialize + DeserializeOwned + Send + Sync + 'static;
13 type Response: Serialize + DeserializeOwned + Send + Sync + 'static;
14}
15
16/// One OCPP-J `SEND` (2.1 only) message: a single payload type with no separate
17/// response, unlike [`Action`]. The wire frame is `[6, MessageId, NAME, Payload]` and the
18/// receiver must never reply to it (see the OCPP-J specification's `SEND` message type) -
19/// `Client::send_notification`/`Client::on_notification` are the fire-and-forget counterparts
20/// to `Action`'s `call`/`on`.
21pub trait SendAction: Send + Sync + 'static {
22 const NAME: &'static str;
23 type Payload: Serialize + DeserializeOwned + Send + Sync + 'static;
24}