pub struct RoundVM {
pub context: Context,
pub export_stack: Vec<Export>,
/* private fields */
}
Expand description
A Round correspond to a local computation in a device. Create the context, evaluate the aggregate program and share the exports to the neighborhood.
-
context
- The context of the current round. -
status
- The status of the current round. -
export_stack
- The stack of exports of the current round.
Fields§
§context: Context
§export_stack: Vec<Export>
Implementations§
source§impl RoundVM
impl RoundVM
sourcepub fn export_data(&mut self) -> &mut Export
pub fn export_data(&mut self) -> &mut Export
sourcepub fn register_root<A: 'static + Copy>(&mut self, v: A)
pub fn register_root<A: 'static + Copy>(&mut self, v: A)
Register the given value for the root path.
Arguments
v
- The value to register.
Generic Parameters
A
- The type of value. It must implement theCopy
trait and have a'static
lifetime.
sourcepub fn neighbor(&self) -> &Option<i32>
pub fn neighbor(&self) -> &Option<i32>
If the computation is folding on a neighbor, return the id of the neighbor
Returns
An &Option<i32>
containing the id of the neighbor, if present
sourcepub fn previous_round_val<A: 'static + Clone>(&self) -> Option<&A>
pub fn previous_round_val<A: 'static + Clone>(&self) -> Option<&A>
Obtain the value of the previous round for the current device and the current path.
Generic Parameters
A
- The type of value. It must implement theClone
trait and have a'static
lifetime.
Returns
An Option
containing the value of the current path for the current device, if present.
sourcepub fn neighbor_val<A: 'static + Clone>(&self) -> Option<&A>
pub fn neighbor_val<A: 'static + Clone>(&self) -> Option<&A>
Obtain the value of the current path for the current neighbor
Generic Parameters
A
- The type of value. It must implement theClone
trait and have a'static
lifetime.
Returns
An Option
containing the value of the current path for the current neighbor, if present.
sourcepub fn local_sense<A: 'static>(&self, sensor_id: &SensorId) -> Option<&A>
pub fn local_sense<A: 'static>(&self, sensor_id: &SensorId) -> Option<&A>
Obtain the local value of a given sensor.
Arguments
-
sensor_id
- The id of the sensor.
Generic Parameters
A
- The type of value returned by the sensor. It must have a'static
lifetime.
Returns
An Option
containing the local value of the given sensor, if present.
sourcepub fn nbr_sense<A: 'static>(&self, sensor_id: &SensorId) -> Option<&A>
pub fn nbr_sense<A: 'static>(&self, sensor_id: &SensorId) -> Option<&A>
Obtain the value of a given sensor for the current neighbor.
Arguments
sensor_id
- The id of the sensor.
Generic Parameters
A
- The type of value returned by the sensor. It must have a'static
lifetime.
Returns
An Option
containing the value of the given sensor for the current neighbor, if present.
sourcepub fn folded_eval<A, F>(&mut self, expr: F, id: i32) -> Option<A>where
F: Fn() -> A,
pub fn folded_eval<A, F>(&mut self, expr: F, id: i32) -> Option<A>where
F: Fn() -> A,
Perform a folded evaluation of the given expression in the given neighbor and return the result.
Arguments
expr
- The expression to evaluate, which should return a value of typeA
.id
- The id of the neighbor.. It is of typei32
.
Generic Parameters
A
- The type of value returned by the expression.F
- The type of the expression, which must be a closure that takes no arguments and returns a value of typeA
.
Returns
An Option
containing the result of the expression.
pub fn nest_in(&mut self, slot: Slot)
pub fn nest_write<A: Copy + 'static>(&mut self, write: bool, value: A) -> A
pub fn nest_out(&mut self, inc: bool)
sourcepub fn aligned_neighbours<A: 'static>(&self) -> Vec<i32>
pub fn aligned_neighbours<A: 'static>(&self) -> Vec<i32>
sourcepub fn isolate<A, F>(&mut self, expr: F) -> Awhere
F: FnMut() -> A,
pub fn isolate<A, F>(&mut self, expr: F) -> Awhere
F: FnMut() -> A,
Isolate the current device and evaluate the given expression
Arguments
expr
- The closure to execute, which takes no arguments and returns a value of typeA
.
Generic Parameters
A
- The type of value returned by the closure.F
- The type of the closure, which must be a mutable closure that takes no arguments and returns a value of typeA
.
Returns
The result of the closure expr
.
sourcepub fn unless_folding_on_others(&self) -> bool
pub fn unless_folding_on_others(&self) -> bool
Check if folding is not being performed on neighbor.
Returns
true
if folding is being performed on self.false
if folding is being performed on neighbor.
sourcepub fn only_when_folding_on_self(&self) -> bool
pub fn only_when_folding_on_self(&self) -> bool
Check if folding is being performed on self.
Returns
true
if folding is being performed on self.false
otherwise.