Skip to main content

Message

Enum Message 

Source
#[non_exhaustive]
pub enum Message {
Show 36 variants Handshake(Handshake), HandshakeResponse(HandshakeResponse), ResourceManagerDetails(Box<ResourceManagerDetails>), SelectControlType(SelectControlType), SessionRequest(SessionRequest), ReceptionStatus(ReceptionStatus), InstructionStatusUpdate(InstructionStatusUpdate), PowerMeasurement(PowerMeasurement), PowerForecast(Box<PowerForecast>), RevokeObject(RevokeObject), PebcPowerConstraints(Box<PowerConstraints>), PebcEnergyConstraint(Box<EnergyConstraint>), PebcInstruction(Box<Instruction>), PpbcPowerProfileDefinition(Box<PowerProfileDefinition>), PpbcPowerProfileStatus(Box<PowerProfileStatus>), PpbcScheduleInstruction(Box<ScheduleInstruction>), PpbcStartInterruptionInstruction(Box<StartInterruptionInstruction>), PpbcEndInterruptionInstruction(Box<EndInterruptionInstruction>), OmbcSystemDescription(Box<SystemDescription>), OmbcStatus(Box<Status>), OmbcTimerStatus(TimerStatus), OmbcInstruction(Box<Instruction>), FrbcSystemDescription(Box<SystemDescription>), FrbcStorageStatus(StorageStatus), FrbcActuatorStatus(Box<ActuatorStatus>), FrbcTimerStatus(Box<TimerStatus>), FrbcLeakageBehaviour(Box<LeakageBehaviour>), FrbcUsageForecast(Box<UsageForecast>), FrbcFillLevelTargetProfile(Box<FillLevelTargetProfile>), FrbcInstruction(Box<Instruction>), DdbcSystemDescription(Box<SystemDescription>), DdbcActuatorStatus(Box<ActuatorStatus>), DdbcTimerStatus(Box<TimerStatus>), DdbcAverageDemandRateForecast(Box<AverageDemandRateForecast>), DdbcPresentDemandStatus(PresentDemandStatus), DdbcInstruction(Box<Instruction>),
}
Expand description

Any S2 message.

The enum is internally tagged by message_type, exactly as the wire is, so serialising a Message produces a complete S2 message and deserialising one accepts any of the 36.

use s2_kit::{Message, types::frbc};

let json = r#"{"message_type":"FRBC.StorageStatus",
               "message_id":"aaaaaaaa-0000-0000-0000-000000000001",
               "present_fill_level":52.0}"#;
let message: Message = serde_json::from_str(json)?;
match &message {
    Message::FrbcStorageStatus(s) => assert_eq!(s.present_fill_level, 52.0),
    _ => unreachable!(),
}

Large payloads are boxed so that the enum stays small enough to pass by value and to keep a queue of pending messages compact; From is implemented for every payload type and does the boxing for you.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Handshake(Handshake)

A node announcing its role and the versions it speaks.

§

HandshakeResponse(HandshakeResponse)

The CEM’s choice of version.

§

ResourceManagerDetails(Box<ResourceManagerDetails>)

Everything static about a resource.

§

SelectControlType(SelectControlType)

The CEM activating a control type.

§

SessionRequest(SessionRequest)

Either side asking for the session to end or restart.

§

ReceptionStatus(ReceptionStatus)

The answer every other message gets.

§

InstructionStatusUpdate(InstructionStatusUpdate)

What became of an instruction.

§

PowerMeasurement(PowerMeasurement)

A measured power.

§

PowerForecast(Box<PowerForecast>)

An expected power.

§

RevokeObject(RevokeObject)

Withdrawing an object published earlier.

§

PebcPowerConstraints(Box<PowerConstraints>)

The bounds within which the CEM may set an envelope.

§

PebcEnergyConstraint(Box<EnergyConstraint>)

How much energy must still flow over a period.

§

PebcInstruction(Box<Instruction>)

The envelope the CEM wants followed.

§

PpbcPowerProfileDefinition(Box<PowerProfileDefinition>)

The task, its window, and every way of performing it.

§

PpbcPowerProfileStatus(Box<PowerProfileStatus>)

How every container of a profile is getting on.

§

PpbcScheduleInstruction(Box<ScheduleInstruction>)

The CEM choosing a sequence and a start time.

§

PpbcStartInterruptionInstruction(Box<StartInterruptionInstruction>)

The CEM pausing a running sequence.

§

PpbcEndInterruptionInstruction(Box<EndInterruptionInstruction>)

The CEM resuming an interrupted sequence.

§

OmbcSystemDescription(Box<SystemDescription>)

The state machine.

§

OmbcStatus(Box<Status>)

Which mode the device is in.

§

OmbcTimerStatus(TimerStatus)

When one of its timers finishes.

§

OmbcInstruction(Box<Instruction>)

The CEM asking for a mode change.

§

FrbcSystemDescription(Box<SystemDescription>)

The storage and every actuator that can move it.

§

FrbcStorageStatus(StorageStatus)

How full the store is.

§

FrbcActuatorStatus(Box<ActuatorStatus>)

Which mode an actuator is in.

§

FrbcTimerStatus(Box<TimerStatus>)

When one of an actuator’s timers finishes.

§

FrbcLeakageBehaviour(Box<LeakageBehaviour>)

The store’s standing losses.

§

FrbcUsageForecast(Box<UsageForecast>)

What the user is expected to take out of the store.

§

FrbcFillLevelTargetProfile(Box<FillLevelTargetProfile>)

Fill levels the CEM should aim for.

§

FrbcInstruction(Box<Instruction>)

The CEM asking an actuator to change mode.

§

DdbcSystemDescription(Box<SystemDescription>)

Every actuator that can meet the demand.

§

DdbcActuatorStatus(Box<ActuatorStatus>)

Which mode an actuator is in.

§

DdbcTimerStatus(Box<TimerStatus>)

When one of an actuator’s timers finishes.

§

DdbcAverageDemandRateForecast(Box<AverageDemandRateForecast>)

What the system expects to be asked for.

§

DdbcPresentDemandStatus(PresentDemandStatus)

The demand that must be satisfied right now. New in S2 JSON v1.0.0.

§

DdbcInstruction(Box<Instruction>)

The CEM asking an actuator to change mode.

Implementations§

Source§

impl Message

Source

pub const fn kind(&self) -> MessageKind

Which message this is.

Source§

impl Message

Source

pub fn id(&self) -> Option<Id>

This message’s own identifier.

None for ReceptionStatus, which has none — it names the message it is about instead, via subject_message_id.

Source

pub fn subject_message_id(&self) -> Option<Id>

The message a ReceptionStatus is about, if this is one.

Source

pub fn instruction_id(&self) -> Option<Id>

The instruction’s own identifier, if this message is an instruction.

This is not the message_id: an InstructionStatusUpdate names this one.

Source

pub fn revokable_id(&self) -> Option<(RevokableObjects, Id)>

The identifier of the object this message publishes, if it is one a RevokeObject could later withdraw.

Source

pub const fn control_type(&self) -> Option<ControlType>

The control type this message belongs to, if any.

Source

pub const fn is_instruction(&self) -> bool

Whether this message is an instruction.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Self

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 Debug for Message

Source§

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

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

impl<'de> Deserialize<'de> for Message

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<ActuatorStatus> for Message

Source§

fn from(value: ActuatorStatus) -> Self

Converts to this type from the input type.
Source§

impl From<ActuatorStatus> for Message

Source§

fn from(value: ActuatorStatus) -> Self

Converts to this type from the input type.
Source§

impl From<AverageDemandRateForecast> for Message

Source§

fn from(value: AverageDemandRateForecast) -> Self

Converts to this type from the input type.
Source§

impl From<EndInterruptionInstruction> for Message

Source§

fn from(value: EndInterruptionInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<EnergyConstraint> for Message

Source§

fn from(value: EnergyConstraint) -> Self

Converts to this type from the input type.
Source§

impl From<FillLevelTargetProfile> for Message

Source§

fn from(value: FillLevelTargetProfile) -> Self

Converts to this type from the input type.
Source§

impl From<Handshake> for Message

Source§

fn from(value: Handshake) -> Self

Converts to this type from the input type.
Source§

impl From<HandshakeResponse> for Message

Source§

fn from(value: HandshakeResponse) -> Self

Converts to this type from the input type.
Source§

impl From<Instruction> for Message

Source§

fn from(value: Instruction) -> Self

Converts to this type from the input type.
Source§

impl From<Instruction> for Message

Source§

fn from(value: Instruction) -> Self

Converts to this type from the input type.
Source§

impl From<Instruction> for Message

Source§

fn from(value: Instruction) -> Self

Converts to this type from the input type.
Source§

impl From<Instruction> for Message

Source§

fn from(value: Instruction) -> Self

Converts to this type from the input type.
Source§

impl From<InstructionStatusUpdate> for Message

Source§

fn from(value: InstructionStatusUpdate) -> Self

Converts to this type from the input type.
Source§

impl From<LeakageBehaviour> for Message

Source§

fn from(value: LeakageBehaviour) -> Self

Converts to this type from the input type.
Source§

impl From<PowerConstraints> for Message

Source§

fn from(value: PowerConstraints) -> Self

Converts to this type from the input type.
Source§

impl From<PowerForecast> for Message

Source§

fn from(value: PowerForecast) -> Self

Converts to this type from the input type.
Source§

impl From<PowerMeasurement> for Message

Source§

fn from(value: PowerMeasurement) -> Self

Converts to this type from the input type.
Source§

impl From<PowerProfileDefinition> for Message

Source§

fn from(value: PowerProfileDefinition) -> Self

Converts to this type from the input type.
Source§

impl From<PowerProfileStatus> for Message

Source§

fn from(value: PowerProfileStatus) -> Self

Converts to this type from the input type.
Source§

impl From<PresentDemandStatus> for Message

Source§

fn from(value: PresentDemandStatus) -> Self

Converts to this type from the input type.
Source§

impl From<ReceptionStatus> for Message

Source§

fn from(value: ReceptionStatus) -> Self

Converts to this type from the input type.
Source§

impl From<ResourceManagerDetails> for Message

Source§

fn from(value: ResourceManagerDetails) -> Self

Converts to this type from the input type.
Source§

impl From<RevokeObject> for Message

Source§

fn from(value: RevokeObject) -> Self

Converts to this type from the input type.
Source§

impl From<ScheduleInstruction> for Message

Source§

fn from(value: ScheduleInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<SelectControlType> for Message

Source§

fn from(value: SelectControlType) -> Self

Converts to this type from the input type.
Source§

impl From<SessionRequest> for Message

Source§

fn from(value: SessionRequest) -> Self

Converts to this type from the input type.
Source§

impl From<StartInterruptionInstruction> for Message

Source§

fn from(value: StartInterruptionInstruction) -> Self

Converts to this type from the input type.
Source§

impl From<Status> for Message

Source§

fn from(value: Status) -> Self

Converts to this type from the input type.
Source§

impl From<StorageStatus> for Message

Source§

fn from(value: StorageStatus) -> Self

Converts to this type from the input type.
Source§

impl From<SystemDescription> for Message

Source§

fn from(value: SystemDescription) -> Self

Converts to this type from the input type.
Source§

impl From<SystemDescription> for Message

Source§

fn from(value: SystemDescription) -> Self

Converts to this type from the input type.
Source§

impl From<SystemDescription> for Message

Source§

fn from(value: SystemDescription) -> Self

Converts to this type from the input type.
Source§

impl From<TimerStatus> for Message

Source§

fn from(value: TimerStatus) -> Self

Converts to this type from the input type.
Source§

impl From<TimerStatus> for Message

Source§

fn from(value: TimerStatus) -> Self

Converts to this type from the input type.
Source§

impl From<TimerStatus> for Message

Source§

fn from(value: TimerStatus) -> Self

Converts to this type from the input type.
Source§

impl From<UsageForecast> for Message

Source§

fn from(value: UsageForecast) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Message

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Message

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Message

Source§

impl Validate for Message

Source§

fn validate_at(&self, path: &str, ctx: &Context<'_>, out: &mut Report)

Check, recording everything wrong at path and below.
Source§

fn validate(&self, ctx: &Context<'_>) -> Report

Check, returning a fresh report.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more