Skip to main content

BindContext

Struct BindContext 

Source
pub struct BindContext<'a> { /* private fields */ }
Expand description

Handed to a sensor during binding so it can declare what it will observe.

Sensors may declare entities of their own, not only channels. A thermal zone and a RAPL power domain are real parts of the machine that the CPU topology knows nothing about, and forcing them to be attributes of a core would be exactly the human-ontology imposition this architecture avoids.

Implementations§

Source§

impl<'a> BindContext<'a>

Source

pub fn new( substrate: &'a Substrate, sensor: SensorId, entities: &'a mut Vec<Entity>, channels: &'a mut Vec<ChannelSpec>, relations: &'a mut Vec<Relation>, ) -> BindContext<'a>

Source

pub fn substrate(&self) -> &Substrate

The structural machine description, including filesystem roots.

Source

pub fn row_of(&self, key: &str) -> Option<u32>

Row index of an already-declared entity, by natural key.

Source

pub fn declare_entity(&mut self, entity: Entity) -> u32

Declare an entity, or return the existing row if its key is already present. Idempotent, so two sensors observing the same physical thing agree about which row it is rather than duplicating it.

Source

pub fn declare_channel( &mut self, key: impl Into<String>, unit: Unit, semantics: Semantics, ) -> ChannelId

Declare a channel and get its column index.

Source

pub fn declare_relation(&mut self, relation: Relation)

Declare an edge.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for BindContext<'a>

§

impl<'a> Freeze for BindContext<'a>

§

impl<'a> RefUnwindSafe for BindContext<'a>

§

impl<'a> Send for BindContext<'a>

§

impl<'a> Sync for BindContext<'a>

§

impl<'a> Unpin for BindContext<'a>

§

impl<'a> UnsafeUnpin for BindContext<'a>

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.