rust_ocpp/v1_6/messages/start_transaction.rs
1use crate::v1_6::types::IdTagInfo;
2
3use chrono::{DateTime, Utc};
4use validator::Validate;
5
6/// This section contains the field definition of the StartTransaction.req PDU sent by the Charge Point to the Central System. See also Start Transaction
7#[derive(serde::Serialize, serde::Deserialize, Validate, Debug, Clone, PartialEq, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct StartTransactionRequest {
10 /// Required. This identifies which connector of the Charge Point is used.
11 pub connector_id: u32,
12 /// Required. This contains the identifier for which a transaction has to be started.
13 #[validate(length(min = 1, max = 20))]
14 pub id_tag: String, // IdToken, should this be a type?
15 /// Required. This contains the meter value in Wh for the connector at start of the transaction.
16 pub meter_start: i32,
17 /// Optional. This contains the id of the reservation that terminates as a result of this transaction.
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub reservation_id: Option<i32>,
20 /// Required. This contains the date and time on which the transaction is started.
21 pub timestamp: DateTime<Utc>,
22}
23
24/// This contains the field definition of the StartTransaction.conf PDU sent by the Central System to the Charge Point in response to a StartTransaction.req PDU. See also Start Transaction
25#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Default)]
26#[serde(rename_all = "camelCase")]
27pub struct StartTransactionResponse {
28 /// Required. This contains information about authorization status, expiry and parent id
29 pub id_tag_info: IdTagInfo,
30 /// Required. This contains the transaction id supplied by the Central System.
31 pub transaction_id: i32,
32}