Skip to main content

AssetWatch

Struct AssetWatch 

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

Subscription handle for one location. One watcher per location; construct multiple instances if the control program cares about multiple roles. Hold onto the AssetWatch for the lifetime of the control program — dropping it leaves the underlying topic subscribed but discards any queued events.

Implementations§

Source§

impl AssetWatch

Source

pub fn new(location: &str, client: &mut CommandClient) -> Self

Subscribe to ams.asset_updated.<location> and issue the initial-sync query. Returns the handle the control program holds for the duration of the run.

client is the CommandClient from TickContext::client. The subscription persists past this call — CommandClient owns the buffer.

Source

pub fn location(&self) -> &str

The location this watcher is bound to.

Source

pub fn initialised(&self) -> bool

True once an InitialSync (or InitialSyncEmpty) has been returned from pump(). Until this flips, subsequent broadcasts are still surfaced — initial-sync just tells the operator “you’ve seen the baseline.”

Source

pub fn is_active(&self) -> bool

true if the watcher’s latest observation is that an active asset is registered at this location. The common control-loop gate: refuse to enter auto when this is false.

Initially false until the first pump() consumes the initial-sync result. After that it tracks broadcasts in real time.

Source

pub fn active_asset_id(&self) -> Option<&str>

asset_id currently filling this role, or None when status is Missing. Useful for logging “running against LC-2026…” and for the per-cycle trail in TIS records.

Source

pub fn active_status(&self) -> AssetWatchStatus

Finer-grained version of is_active. Use when a control program needs to distinguish (e.g.) Retired from OutForService to drive different operator messaging.

Source

pub fn pump(&mut self, client: &mut CommandClient) -> Vec<AssetUpdate>

Per-tick drain. Returns every event since the previous call, in arrival order. Empty when no events are pending.

The first non-empty return (assuming the ams.list_assets response has arrived) starts with either InitialSync or InitialSyncEmpty, followed by any broadcasts that landed before the response did.

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
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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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