pub trait Scheduler<E: SEEvent> {
    type Program;

    // Required methods
    fn new(
        client: Client,
        device: Arc<RwLock<SEDevice>>,
        handler: impl EventCallback<E>,
        tickrate: Duration
    ) -> Self;
    fn add_event<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        event: E,
        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.
Expand description

A Trait representing the common interface of all schedules.

Required Associated Types§

source

type Program

The type of the program the specific SEEvent belongs to, containing a primacy value and a unique program MRID.

Required Methods§

source

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

Create a new Schedule for a particular function set.

Any Client instance with an appropriate certificate can be used, as automated Response POST requests will be made to the replyTo field in the event, which is an absolute URI.

An Arc<RwLock<SEDevice>> is supplied to allow the schedule to retrieve the latest information about the device when creating automated responses.

The specified Handler will be called whenever there is an event status update that requires a response from the client.

The given tickrate determines how often the Schedule should wake from sleep to check if an event has started or ended.

source

fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: E, 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,

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.

Events from different servers should be added with different server ids, the ids chosen are irrelevant.

Subsequent retrievals/notifications of any and all SEEvent resources should call this function.

Implementors§

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§

impl Scheduler<EndDeviceControl> for Schedule<EndDeviceControl>

Available on crate feature drlc only.
source§

impl Scheduler<FlowReservationResponse> for Schedule<FlowReservationResponse>

Available on crate feature flow_reservation only.
§

type Program = ()

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.

source§

impl Scheduler<TimeTariffInterval> for Schedule<TimeTariffInterval>

Available on crate feature pricing only.