Skip to main content

Reflector

Struct Reflector 

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

A live producer of reflections.

One Reflector owns one machine’s observation loop. Calling Reflector::observe advances it to the present; nothing else changes it. No consumer, model or agent can write to a reflection. The only way to change what the mirror shows is to change the machine.

Implementations§

Source§

impl Reflector

Source

pub fn build( substrate: Substrate, sensors: Vec<Box<dyn Sensor>>, ) -> Result<Reflector>

Discover structure, then bind every sensor to it.

Binding is where all the once-per-epoch work happens: paths are constructed, capabilities probed, descriptors opened, entities and channels declared. A sensor that cannot bind is not an error. It is recorded as inactive with a reason, and the mirror says so rather than implying this machine has no thermal sensors.

Source

pub fn build_at_epoch( substrate: Substrate, sensors: Vec<Box<dyn Sensor>>, epoch: u64, ) -> Result<Reflector>

Build at a given epoch, for a rebuild after the machine’s shape changed.

Source

pub fn substrate(&self) -> &Substrate

Source

pub fn epoch(&self) -> u64

Source

pub fn entities(&self) -> &[Entity]

Source

pub fn channels(&self) -> &[ChannelSpec]

Source

pub fn relations(&self) -> &[Relation]

Source

pub fn observe(&mut self)

Advance the reflection to the present.

Source

pub fn snapshot(&self) -> MirrorSnapshot

The current reflection, as an owned snapshot.

Source

pub fn last_observation_cost_ns(&self) -> u64

Total time the last observation pass spent looking.

Source

pub fn inactive_sensors(&self) -> Vec<&SensorReport>

Sensors that could not bind on this machine, and why.

Source

pub fn shape_changed(&self) -> bool

Whether the machine’s shape has changed since this reflector was built.

Cheap enough to call every tick. When it returns true the caller should rebuild at a higher epoch, because every row index it holds is stale.

Trait Implementations§

Source§

impl Debug for Reflector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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