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
impl Reflector
Sourcepub fn build(
substrate: Substrate,
sensors: Vec<Box<dyn Sensor>>,
) -> Result<Reflector>
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.
Sourcepub fn build_at_epoch(
substrate: Substrate,
sensors: Vec<Box<dyn Sensor>>,
epoch: u64,
) -> Result<Reflector>
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.
pub fn substrate(&self) -> &Substrate
pub fn epoch(&self) -> u64
pub fn entities(&self) -> &[Entity]
pub fn channels(&self) -> &[ChannelSpec]
pub fn relations(&self) -> &[Relation]
Sourcepub fn snapshot(&self) -> MirrorSnapshot
pub fn snapshot(&self) -> MirrorSnapshot
The current reflection, as an owned snapshot.
Sourcepub fn last_observation_cost_ns(&self) -> u64
pub fn last_observation_cost_ns(&self) -> u64
Total time the last observation pass spent looking.
Sourcepub fn inactive_sensors(&self) -> Vec<&SensorReport>
pub fn inactive_sensors(&self) -> Vec<&SensorReport>
Sensors that could not bind on this machine, and why.
Sourcepub fn shape_changed(&self) -> bool
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.