Skip to main content

LocalDevice

Struct LocalDevice 

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

Device state for one authorized route.

Completed operations are retained for at least the configured replay window. Size the window for broker message expiry and the equipment’s retry policy.

Implementations§

Source§

impl LocalDevice

Source

pub fn initialize_trust( &mut self, trust: Vec<TrustEntry>, ) -> Result<(), EngineError>

Import a previously commissioned equipment inventory once on a fresh local route. Later changes use a confirmed replacement or Self::pairing_established.

Source

pub fn trust_revision(&self) -> Option<u64>

Revision of the active local trust replacement. Capture this value when starting asynchronous SHIP pairing. Each newly accepted replacement advances the revision, including a successful clear. A replayed control returns its saved outcome and leaves the revision unchanged. Device checkpoints preserve it on restart.

Source

pub fn pairing_established( &mut self, revision: u64, for_id: &str, for_par: &str, ski: &str, ) -> Result<bool, EngineError>

Record the authenticated SHIP peer’s SKI in its original pairing entry. Returns true for a new observation and false for an identical duplicate. The revision, case-sensitive SHIP ID and certificate fingerprint must match. A pending replacement requires reconciliation before reporting a result. On success, checkpoint the updated inventory before publishing its readback. The original pairing ID, fingerprint and secret remain in the authorized state response. KEO 1.2.0 state trust semantics

Source§

impl LocalDevice

Source

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

Create a point-in-time checkpoint. It can contain pairing secrets. Store atomically under application access controls, before actuation and before sending its acknowledgement.

Source

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

Resume from an application-controlled checkpoint using externally provisioned identity, target kind, capacity and replay window. Use a fresh engine and synchronized UTC. Commit checkpoints atomically with one writer per route and protect them against rollback. Recovered pending operations remain blocked from dispatch until equipment confirms their outcome.

Source§

impl LocalDevice

Source

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

Create an engine with a 24-hour replay window and a hard entry/meter capacity.

Source

pub fn with_replay_window(self, seconds: u64) -> Result<Self, EngineError>

Set the minimum retention for completed IDs. Configure before admitting any operation.

Source

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

Inspect operations requiring equipment reconciliation, including after restart.

Source

pub fn control_for_dispatch( &mut self, id: &str, now: Clock, ) -> Result<Option<Control>, EngineError>

Recalculate a queued operation immediately before its first equipment write. A timed activation or deactivation which expired in the queue returns None; complete it as rejected. Restored pending operations require independent reconciliation before any reissue.

Source

pub fn read_control(&mut self, id: &str) -> Result<Message, EngineError>

Request the backend’s accumulated control. Only one read can be outstanding.

Source

pub fn cancel_read(&mut self)

Cancel the outstanding local read on timeout.

Source

pub fn capabilities( &mut self, id: &str, values: Vec<String>, now: Clock, ) -> Result<Message, EngineError>

Update locally discovered capabilities and return an immediate state advertisement.

Source

pub fn observe_meters(&mut self, meters: Vec<Meter>) -> Result<(), EngineError>

Replace observations with the adapter’s complete source inventory. Omit lost sources and invalid readings. Readback then reflects the current inventory immediately.

Source

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

Build current state at the supplied time without emitting a notification.

Source

pub fn notification( &mut self, id: &str, now: Clock, ) -> Result<Option<Message>, EngineError>

Poll an active notification schedule. A late poll coalesces missed intervals.

Source

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

Process a validated publication for this route. Equipment must only act on DeviceEvent::Apply.

Source

pub fn complete( &mut self, request_id: &str, outcome: Outcome, now: Clock, ) -> Result<Option<Message>, EngineError>

Record downstream acceptance or failure. Unknown results stay pending. If acceptance times out, reconcile equipment before calling this again. Related controls have no ack.

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.