pub struct StatePayload {
pub online: bool,
pub timestamp: i64,
}Expand description
A Host Application STATE message body.
Fields§
§online: boolWhether the Host Application is online.
timestamp: i64Epoch milliseconds (UTC) of this state.
Implementations§
Source§impl StatePayload
impl StatePayload
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
Serialize to the canonical JSON form {"online":<bool>,"timestamp":<ms>}.
Sourcepub fn parse(json: &str) -> Result<Self>
pub fn parse(json: &str) -> Result<Self>
Parse a STATE JSON payload.
Tolerant of whitespace and key order; requires both online and
timestamp. The STATE object has no nested structure, so this small
hand parser is sufficient and total.
§Errors
Returns SparkplugError::InvalidState for malformed JSON, a missing
key, or an out-of-form value.
Trait Implementations§
Source§impl Clone for StatePayload
impl Clone for StatePayload
Source§fn clone(&self) -> StatePayload
fn clone(&self) -> StatePayload
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for StatePayload
Source§impl Debug for StatePayload
impl Debug for StatePayload
impl Eq for StatePayload
Source§impl PartialEq for StatePayload
impl PartialEq for StatePayload
Source§fn eq(&self, other: &StatePayload) -> bool
fn eq(&self, other: &StatePayload) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for StatePayload
Auto Trait Implementations§
impl Freeze for StatePayload
impl RefUnwindSafe for StatePayload
impl Send for StatePayload
impl Sync for StatePayload
impl Unpin for StatePayload
impl UnsafeUnpin for StatePayload
impl UnwindSafe for StatePayload
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more