Skip to main content

Backend

Struct Backend 

Source
pub struct Backend { /* private fields */ }
Expand description

Backend role for one authorized route. Callers schedule timeouts via Self::cancel.

Implementations§

Source§

impl Backend

Source

pub fn checkpoint(&mut self, now: Clock) -> Result<Vec<u8>, EngineError>

Checkpoint before publishing a newly registered control and again after its ACK. Store these potentially credential-bearing bytes atomically under exclusive route ownership.

Source

pub fn restore(self, bytes: &[u8], now: Clock) -> Result<Self, EngineError>

Recover using externally provisioned route, source and capacity. Restored commands await the original ACK. A state read can reconcile uncertain equipment while conflicting writes and desired-control replies stay blocked. Explicit cancellation abandons correlation.

Source§

impl Backend

Source

pub fn new( route: impl Into<String>, source: impl Into<String>, capacity: usize, ) -> Self

capacity bounds outstanding controls and cached meters. A separate slot permits one state read even while every control slot awaits reconciliation.

Source

pub fn state(&self) -> Option<&State>

Latest validated observations for this route. The aggregate timestamp is the greatest accepted message timestamp. Individual properties may come from earlier messages.

Source

pub fn property_observed_at(&self, field: &str) -> Option<i64>

Device timestamp of the last accepted observation or authoritative clear of a wire field. For measurements this is the latest time across its inventory and individual sources.

Source

pub fn meter_observed_at(&self, id: &str) -> Option<i64>

Device timestamp of the cached reading for a particular meter, in Unix seconds.

Source

pub fn cancel(&mut self, id: &str) -> bool

Cancel a request after timeout. A later reply cannot update the cache through this ID. Request IDs must be unique across retries and restarts.

Source

pub fn pending_controls(&self) -> impl Iterator<Item = (&str, &Control)>

Outstanding operations whose equipment outcome still needs confirmation. These entries survive checkpoint restore and are never republished by the engine.

Source

pub fn confirmed_settings(&mut self, now: Clock) -> Result<Control, EngineError>

Confirmed desired settings, including remaining or expired lifetimes. Both power directions can be represented in memory even where the 1.2.0 reply cannot carry both.

Source

pub fn send_control( &mut self, id: &str, request: Control, now: Clock, ) -> Result<Message, EngineError>

Register a standalone control before transmitting. Only one per family may be outstanding.

Source

pub fn read( &mut self, id: &str, parameters: Vec<String>, ) -> Result<Message, EngineError>

Register a state read. Empty parameters request a full snapshot.

Source

pub fn receive( &mut self, route: &str, message: &Message, reply_id: &str, now: Clock, ) -> Result<BackendEvent, EngineError>

Consume a verified message received on the provisioned target. reply_id is used on replies.

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
§

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

§

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

§

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

§

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

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

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