pub struct Context<'a> {Show 20 fields
pub profile: WireProfile,
pub sender: Option<EnergyManagementRole>,
pub phase: Phase,
pub s2_connect: bool,
pub details: Option<&'a ResourceManagerDetails>,
pub frbc: Option<&'a SystemDescription>,
pub ombc: Option<&'a SystemDescription>,
pub ddbc: Option<&'a SystemDescription>,
pub pebc_constraints: &'a [PowerConstraints],
pub ppbc_profiles: &'a [PowerProfileDefinition],
pub instructions: &'a [Id],
pub instruction_messages: &'a [(Id, Id)],
pub instruction_statuses: &'a [(Id, InstructionStatus)],
pub seen_message_ids: &'a [Id],
pub published: &'a [(RevokableObjects, Id)],
pub active_modes: &'a [(Id, Id)],
pub timers: &'a [TimerState],
pub fill_level: Option<f64>,
pub now: Option<Timestamp>,
pub skew_tolerance: Duration,
}Expand description
What the cross-message rules need to know.
Context::empty runs the rules that need nothing but the message in front of them,
which is what makes the validator usable on a lone JSON file. A session fills in the
rest.
Fields are public and the struct is deliberately not #[non_exhaustive]: a
proxy, an analyzer or a test builds one with Context { frbc: Some(&system), ..Context::empty() }, and a marker that forbids struct-update syntax would take that
away for the sake of a guarantee this crate does not need before 1.0.
Fields§
§profile: WireProfileThe negotiated wire profile.
sender: Option<EnergyManagementRole>Which role sent the message being validated.
phase: PhaseWhere the session has got to: negotiating, connected, or a control type active.
The row of S2C §State of communication this message is being judged against.
s2_connect: boolWhether the session is running under S2 Connect, where the handshake messages must not appear.
details: Option<&'a ResourceManagerDetails>The resource’s details, once it has sent them.
frbc: Option<&'a SystemDescription>The effective FRBC system description.
ombc: Option<&'a SystemDescription>The effective OMBC system description.
ddbc: Option<&'a SystemDescription>The effective DDBC system description.
pebc_constraints: &'a [PowerConstraints]Power constraints currently published.
ppbc_profiles: &'a [PowerProfileDefinition]Power profiles currently published.
instructions: &'a [Id]Instruction identifiers the CEM has already used.
instruction_messages: &'a [(Id, Id)](message_id, instruction_id) for each of them, so that a status update naming
the wrong one of the two can say which mistake was made.
instruction_statuses: &'a [(Id, InstructionStatus)]The latest status of each instruction.
seen_message_ids: &'a [Id]Message identifiers already seen this session.
published: &'a [(RevokableObjects, Id)]Objects published this session, and so revokable.
active_modes: &'a [(Id, Id)]The operation mode each actuator is in, keyed by actuator (Id::NIL for OMBC,
which has a single machine).
timers: &'a [TimerState]When each actuator’s timers finish.
fill_level: Option<f64>The present fill level, once the storage has reported one.
now: Option<Timestamp>The local clock, for the skew rule.
skew_tolerance: DurationHow far a peer’s clock may differ before it is worth reporting.
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn with_details(self, details: &'a ResourceManagerDetails) -> Self
pub fn with_details(self, details: &'a ResourceManagerDetails) -> Self
With the resource’s details, which several rules need.
Sourcepub fn sent_by(self, sender: EnergyManagementRole) -> Self
pub fn sent_by(self, sender: EnergyManagementRole) -> Self
With the role that sent the message, which the state rules need.
Sourcepub fn active(self, control_type: ControlType) -> Self
pub fn active(self, control_type: ControlType) -> Self
With a control type active, which the state rules need.
Sourcepub const fn in_phase(self, phase: Phase) -> Self
pub const fn in_phase(self, phase: Phase) -> Self
With the session in a particular phase, which the state rules need.
Sourcepub const fn active_control_type(&self) -> Option<ControlType>
pub const fn active_control_type(&self) -> Option<ControlType>
The control type that is active, if one that can be instructed is.