pub struct RoundVM { /* 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.
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 + Clone>(&mut self, v: A)
pub fn register_root<A: 'static + Clone>(&mut self, v: A)
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 + FromStr>(&self) -> Result<A>
pub fn previous_round_val<A: 'static + Clone + FromStr>(&self) -> Result<A>
Sourcepub fn neighbor_val<A: 'static + Clone + FromStr>(&self) -> Result<A>
pub fn neighbor_val<A: 'static + Clone + FromStr>(&self) -> Result<A>
Sourcepub fn local_sense<A: 'static>(&self, sensor_id: &SensorId) -> Option<&A>
pub fn local_sense<A: 'static>(&self, sensor_id: &SensorId) -> Option<&A>
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 locally<A: Clone + 'static + FromStr, F>(&mut self, expr: F) -> A
pub fn locally<A: Clone + 'static + FromStr, F>(&mut self, expr: F) -> A
Evaluates the given expression locally and return the result.
§Arguments
expr
The expression to evaluate, which takes a RoundVM as argument and returns a tuple ofRoundVM
andA
.
§Generic Parameters
A
- The type of value returned by the expression.F
- The type of the closure, which must be a mutable closure that takes a RoundVM as argument and returns a tuple ofRoundVM
andA
.
§Returns
The result of the closure expr
.
Sourcepub fn folded_eval<A: Clone + 'static, F>(
&mut self,
expr: F,
id: i32,
) -> Option<A>
pub fn folded_eval<A: Clone + 'static, F>( &mut self, expr: F, id: i32, ) -> Option<A>
Perform a folded evaluation of the given expression in the given neighbor and return the result.
§Arguments
expr
- The expression to evaluate, which takes a RoundVM as argument and returns a tuple ofRoundVM
andA
.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 a RoundVM as argument and returns a tuple ofRoundVM
andA
.
§Returns
An Option
containing the result of the expression.
Sourcepub fn nest<A: Clone + 'static + FromStr, F>(
&mut self,
slot: Slot,
write: bool,
inc: bool,
expr: F,
) -> A
pub fn nest<A: Clone + 'static + FromStr, F>( &mut self, slot: Slot, write: bool, inc: bool, expr: F, ) -> A
Evaluate the given expression while also writing on the Export stack.
§Arguments
slot
- The slot to write in the current Path.write
- A boolean indicating whether to write the result of the expression on theExport
stack.inc
- A boolean indicating whether to increment the index of the current [VMStatus].expr
- The expression to evaluate, which takes a RoundVM as argument and returns a tuple ofRoundVM
andA
.
§Generic Parameters
A
- The type of value returned by the expression.F
- The type of the expression, which must be a closure that takes a RoundVM as argument and returns a tuple ofRoundVM
andA
.
§Returns
A tuple of RoundVM
and A
.
Sourcepub fn isolate<A, F>(&mut self, expr: F) -> A
pub fn isolate<A, F>(&mut self, expr: F) -> A
Isolate the current device and evaluate the given expression
§Arguments
expr
- The closure to execute, which takes a RoundVM as argument and returns a tuple ofRoundVM
andA
.
§Generic Parameters
A
- The type of value returned by the closure.F
- The type of the closure, which must be a mutable closure takes a RoundVM as argument and returns a tuple ofRoundVM
andA
.
§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.