Skip to main content

Context

Struct Context 

Source
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: WireProfile

The negotiated wire profile.

§sender: Option<EnergyManagementRole>

Which role sent the message being validated.

§phase: Phase

Where 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: bool

Whether 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: Duration

How far a peer’s clock may differ before it is worth reporting.

Implementations§

Source§

impl<'a> Context<'a>

Source

pub fn empty() -> Self

A context that knows nothing, so only the intra-message rules run.

Source

pub fn with_details(self, details: &'a ResourceManagerDetails) -> Self

With the resource’s details, which several rules need.

Source

pub fn at(self, now: Timestamp) -> Self

With a clock, which the timer and skew rules need.

Source

pub fn sent_by(self, sender: EnergyManagementRole) -> Self

With the role that sent the message, which the state rules need.

Source

pub fn active(self, control_type: ControlType) -> Self

With a control type active, which the state rules need.

Source

pub const fn in_phase(self, phase: Phase) -> Self

With the session in a particular phase, which the state rules need.

Source

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

The control type that is active, if one that can be instructed is.

Source

pub fn is_empty(&self) -> bool

Whether cross-message rules can run at all.

Trait Implementations§

Source§

impl<'a> Clone for Context<'a>

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<'a> Copy for Context<'a>

Source§

impl<'a> Debug for Context<'a>

Source§

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

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

impl<'a> Default for Context<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Forget for Context<'a>

§

impl<'a> Freeze for Context<'a>

§

impl<'a> RefUnwindSafe for Context<'a>

§

impl<'a> Send for Context<'a>

§

impl<'a> Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnsafeUnpin for Context<'a>

§

impl<'a> UnwindSafe for Context<'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<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> 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