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)
Register the given value for the root path.
Arguments
v- The value to register.
Generic Parameters
A- The type of value. It must implement theCopytrait and have a'staticlifetime.
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>
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 theClonetrait and have a'staticlifetime.
Returns
An Option containing the value of the current path for the current device, if present.
sourcepub fn neighbor_val<A: 'static + Clone + FromStr>(&self) -> Result<A>
pub fn neighbor_val<A: 'static + Clone + FromStr>(&self) -> Result<A>
Obtain the value of the current path for the current neighbor
Generic Parameters
A- The type of value. It must implement theClonetrait and have a'staticlifetime.
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'staticlifetime.
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'staticlifetime.
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
) -> (RoundVM, A)
pub fn locally<A: Clone + 'static + FromStr, F>( &mut self, expr: F ) -> (RoundVM, A)
Evaluates the given expression locally and return the result.
Arguments
exprThe expression to evaluate, which takes a RoundVM as argument and returns a tuple ofRoundVMandA.
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 ofRoundVMandA.
Returns
The result of the closure expr.
sourcepub fn folded_eval<A: Clone + 'static, F>(
&mut self,
expr: F,
id: i32
) -> (RoundVM, Option<A>)
pub fn folded_eval<A: Clone + 'static, F>( &mut self, expr: F, id: i32 ) -> (RoundVM, 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 ofRoundVMandA.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 ofRoundVMandA.
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
) -> (RoundVM, A)
pub fn nest<A: Clone + 'static + FromStr, F>( &mut self, slot: Slot, write: bool, inc: bool, expr: F ) -> (RoundVM, 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 theExportstack.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 ofRoundVMandA.
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 ofRoundVMandA.
Returns
A tuple of RoundVM and A.
sourcepub fn isolate<A, F>(&mut self, expr: F) -> (RoundVM, A)
pub fn isolate<A, F>(&mut self, expr: F) -> (RoundVM, 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 ofRoundVMandA.
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 ofRoundVMandA.
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
trueif folding is being performed on self.falseif 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
trueif folding is being performed on self.falseotherwise.