Skip to main content

Frame

Enum Frame 

Source
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

§id: MessageId

Correlation id.

§action: Cow<'a, str>

Action name, exactly as received.

§payload: Cow<'a, RawValue>

Unparsed payload object.

§

CallResult

[3, "<id>", {payload}]

Fields

§id: MessageId

The id of the CALL being answered.

§payload: Cow<'a, RawValue>

Unparsed payload object.

§

CallError

[4, "<id>", "<code>", "<description>", {details}]

Fields

§id: MessageId

The id of the CALL being answered.

§error: CallErrorRef<'a>

The error.

§

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.

Fields

§id: MessageId

The id of the CALLRESULT being rejected.

§error: CallErrorRef<'a>

The error.

§

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).

Fields

§id: MessageId

Identifies the message; never correlated with a response.

§action: Cow<'a, str>

Action name, exactly as received.

§payload: Cow<'a, RawValue>

Unparsed payload object.

Implementations§

Source§

impl<'a> Frame<'a>

Source

pub const fn message_type(&self) -> MessageTypeId

The message type of this frame.

Source

pub fn id(&self) -> &MessageId

The correlation id.

Source

pub fn action(&self) -> Option<&str>

The action name, for the frame types that carry one.

Source

pub fn payload(&self) -> Option<&RawValue>

The unparsed payload, for the frame types that carry one.

Source

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 per version (2.0.1 answers MessageTypeNotSupported, 1.6J and 2.1 ignore it).

Source

pub fn to_json(&self, version: Version) -> Result<String, Error>

Serializes the frame using version’s spelling of the error codes.

Source

pub fn into_owned(self) -> Frame<'static>

Detaches the frame from the buffer it was parsed from.

Trait Implementations§

Source§

impl<'a> Clone for Frame<'a>

Source§

fn clone(&self) -> Frame<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Frame<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Frame<'_>

Source§

fn eq(&self, other: &Self) -> bool

Payloads compare by their raw JSON text, so a frame is equal to itself after a parse/serialize round trip only when the bytes match.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Frame<'a>

§

impl<'a> RefUnwindSafe for Frame<'a>

§

impl<'a> Send for Frame<'a>

§

impl<'a> Sync for Frame<'a>

§

impl<'a> Unpin for Frame<'a>

§

impl<'a> UnsafeUnpin for Frame<'a>

§

impl<'a> UnwindSafe for Frame<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.