pub struct Context { /* private fields */ }
Expand description
§Context implementation
-
selfId
The ID of the device that this context is for. -
local_sensor
The values perceived by the local sensors of the device. -
nbr_sensor
The values perceived by the sensors for each neighbor of the device. -
exports
All the export that are available to the device.
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(
self_id: i32,
local_sensor: LocalSensors,
nbr_sensor: NbrSensors,
exports: Exports,
) -> Self
pub fn new( self_id: i32, local_sensor: LocalSensors, nbr_sensor: NbrSensors, exports: Exports, ) -> Self
Create new Context of a device from the given parameters.
§Arguments
-
self_id
- the ID of the device -
local_sensor
- The values perceived by the local sensors of the device. -
nbr_sensor
- The values perceived by the sensors for each neighbor of the device. -
exports
- All the export that are available to the device.
§Returns
The new Context.
pub fn self_id(&self) -> &i32
pub fn exports(&self) -> &Exports
Sourcepub fn put_export(&mut self, id: i32, data: Export)
pub fn put_export(&mut self, id: i32, data: Export)
Add an export of a device to the context.
§Arguments
id
the ID of the devicedata
the export of the device
Sourcepub fn read_export_value<A: 'static + FromStr + Clone>(
&self,
id: &i32,
path: &Path,
) -> Result<A>
pub fn read_export_value<A: 'static + FromStr + Clone>( &self, id: &i32, path: &Path, ) -> Result<A>
pub fn local_sensors(&self) -> &LocalSensors
Sourcepub fn local_sense<A: 'static>(&self, local_sensor_id: &SensorId) -> Option<&A>
pub fn local_sense<A: 'static>(&self, local_sensor_id: &SensorId) -> Option<&A>
pub fn nbr_sensors(&self) -> &NbrSensors
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more