pub enum Frame<'a> {
Call {
id: MessageId,
action: Cow<'a, str>,
payload: Cow<'a, RawValue>,
},
CallResult {
id: MessageId,
payload: Cow<'a, RawValue>,
},
CallError {
id: MessageId,
error: CallErrorRef<'a>,
},
CallResultError {
id: MessageId,
error: CallErrorRef<'a>,
},
Send {
id: MessageId,
action: Cow<'a, str>,
payload: Cow<'a, RawValue>,
},
}Expand description
One OCPP-J frame.
Borrows from the text it was parsed from; Frame::into_owned detaches it.
Variants§
Call
[2, "<id>", "<action>", {payload}]
Fields
CallResult
[3, "<id>", {payload}]
Fields
CallError
[4, "<id>", "<code>", "<description>", {details}]
CallResultError
[5, "<id>", "<code>", "<description>", {details}] — OCPP 2.1.
Sent when a received CALLRESULT could not be processed, so the original sender
learns that its request did not really succeed.
Send
[6, "<id>", "<action>", {payload}] — OCPP 2.1.
Unconfirmed: it is never answered, and it may be transmitted while a CALL is
outstanding (Part 4 §4.2.4).
Implementations§
Source§impl<'a> Frame<'a>
impl<'a> Frame<'a>
Sourcepub const fn message_type(&self) -> MessageTypeId
pub const fn message_type(&self) -> MessageTypeId
The message type of this frame.
Sourcepub fn payload(&self) -> Option<&RawValue>
pub fn payload(&self) -> Option<&RawValue>
The unparsed payload, for the frame types that carry one.
Sourcepub fn parse(text: &'a str, version: Version) -> Result<Self, FrameError>
pub fn parse(text: &'a str, version: Version) -> Result<Self, FrameError>
Parses one OCPP-J text frame.
version decides which message types are accepted; a frame whose type number is not
defined at all yields FrameError::UnknownMessageType, which the caller must handle
by ignoring the message (1.6J §4.1.3, 2.x §4.1).
Sourcepub fn to_json(&self, version: Version) -> Result<String, Error>
pub fn to_json(&self, version: Version) -> Result<String, Error>
Serializes the frame using version’s spelling of the error codes.
Sourcepub fn into_owned(self) -> Frame<'static>
pub fn into_owned(self) -> Frame<'static>
Detaches the frame from the buffer it was parsed from.