Struct sep2_client::event::Schedule

source ·
pub struct Schedule<E>where
    E: SEEvent,{ /* private fields */ }
Available on crate feature event only.
Expand description

Schedule for a given function set, and a specific server.

Schedules are bound by the SEEvent pertaining to a specific function set, and an EventCallback that is passed event updates, such that clients can make device changes, and dictate the response sent to the server.

Multi-server interactions are handled gracefully as the replyTo field on Events contains the hostname of the server.

A Schedule instance is a handle to a handful of shared state. Cloning this struct is relatively cheap, and will involve incrementing all internal atomic reference counts.

However, schedules currently do not clean up their background tasks when all are dropped, thus Schedule::shutdown will perform a graceful shutdown.

Implementations§

source§

impl<E> Schedule<E>where E: SEEvent,

source

pub fn update_time(&mut self, time: Time)

Updates the schedule-specific time offset. “If FunctionSetAssignments contain both Event-based function sets (e.g., DRLC, pricing, message) and a Time resource, then devices SHALL use the Time resource from the same FunctionSetAssignments when executing the events from the associated Event-based function set.”

source

pub fn shutdown(&mut self)

Trait Implementations§

source§

impl<E> Clone for Schedule<E>where E: SEEvent,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Scheduler<DERControl> for Schedule<DERControl>

Available on crate feature der only.

DER is a function set where events exhibit ‘direct control’, according to the specification. Thus, this Schedule will determine when overlapping or superseded events should be superseded based off their target, their primacy, and their creation time and when they are no longer superseded, if their superseding event is cancelled.

source§

fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<DERControl>, tickrate: Duration ) -> Self

Available on crate feature event only.

Create a schedule for the given Client & it’s SEDevice representation.

Any instance of Client can be used, as responses are made in accordance to the hostnames within the provided events.

§

type Program = DERProgram

Available on crate feature event only.
The type of the program the specific SEEvent belongs to, containing a primacy value and a unique program MRID.
source§

fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: DERControl, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Available on crate feature event only.
Add a type implementing SEEvent to the schedule. The concrete type depends on the type of schedule. The program the event belongs to is also required, to determine the primacy of the event, and to send the appropriate response for events that get superseded by other programs. Read more
source§

impl Scheduler<EndDeviceControl> for Schedule<EndDeviceControl>

Available on crate feature drlc only.
§

type Program = DemandResponseProgram

Available on crate feature event only.
The type of the program the specific SEEvent belongs to, containing a primacy value and a unique program MRID.
source§

fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<EndDeviceControl>, tickrate: Duration ) -> Self

Available on crate feature event only.
Create a new Schedule for a particular function set. Read more
source§

fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: EndDeviceControl, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Available on crate feature event only.
Add a type implementing SEEvent to the schedule. The concrete type depends on the type of schedule. The program the event belongs to is also required, to determine the primacy of the event, and to send the appropriate response for events that get superseded by other programs. Read more
source§

impl Scheduler<FlowReservationResponse> for Schedule<FlowReservationResponse>

Available on crate feature flow_reservation only.
§

type Program = ()

Available on crate feature event only.
The type of the program the specific SEEvent belongs to, containing a primacy value and a unique program MRID.
source§

fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<FlowReservationResponse>, tickrate: Duration ) -> Self

Available on crate feature event only.
Create a new Schedule for a particular function set. Read more
source§

fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: FlowReservationResponse, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Available on crate feature event only.
Add a type implementing SEEvent to the schedule. The concrete type depends on the type of schedule. The program the event belongs to is also required, to determine the primacy of the event, and to send the appropriate response for events that get superseded by other programs. Read more
source§

impl Scheduler<TextMessage> for Schedule<TextMessage>

Available on crate feature messaging only.

Messaging is NOT a function set where events exhibit ‘direct control’. Unlike direct control function sets, multiple text messages can be active at any given time.

This schedule simply calls the given handler when the start time arrives, if and when the event is cancelled, The supplied handler is given the primacy, and the priority of the text message, and it is up to them how they are displayed.

TODO: This implementation currently does not support manual acknowledgement of text messages, as while the client’s handler is called, a lock is acquired on the scheduler, meaning it cannot progress.

§

type Program = MessagingProgram

Available on crate feature event only.
The type of the program the specific SEEvent belongs to, containing a primacy value and a unique program MRID.
source§

fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<TextMessage>, tickrate: Duration ) -> Self

Available on crate feature event only.
Create a new Schedule for a particular function set. Read more
source§

fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: TextMessage, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Available on crate feature event only.
Add a type implementing SEEvent to the schedule. The concrete type depends on the type of schedule. The program the event belongs to is also required, to determine the primacy of the event, and to send the appropriate response for events that get superseded by other programs. Read more
source§

impl Scheduler<TimeTariffInterval> for Schedule<TimeTariffInterval>

Available on crate feature pricing only.
§

type Program = (TariffProfile, RateComponent)

Available on crate feature event only.
The type of the program the specific SEEvent belongs to, containing a primacy value and a unique program MRID.
source§

fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<TimeTariffInterval>, tickrate: Duration ) -> Self

Available on crate feature event only.
Create a new Schedule for a particular function set. Read more
source§

fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: TimeTariffInterval, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Available on crate feature event only.
Add a type implementing SEEvent to the schedule. The concrete type depends on the type of schedule. The program the event belongs to is also required, to determine the primacy of the event, and to send the appropriate response for events that get superseded by other programs. Read more

Auto Trait Implementations§

§

impl<E> !RefUnwindSafe for Schedule<E>

§

impl<E> Send for Schedule<E>

§

impl<E> Sync for Schedule<E>

§

impl<E> Unpin for Schedule<E>

§

impl<E> !UnwindSafe for Schedule<E>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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