Struct rf_core::vm::round_vm::RoundVM

source ·
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

source

pub fn new(context: Context) -> Self

Create a new RoundVM

Arguments
  • context - The context of the current round.
Returns

A RoundVM instance.

source

pub fn export_data(&mut self) -> &mut Export

Get the first export of the stack.

Returns

The first export of the stack, of type &mut Export.

source

pub fn self_id(&self) -> i32

Returns

The id of the device, of type i32.

source

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 the Copy trait and have a 'static lifetime.
source

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

source

pub fn index(&self) -> &i32

Returns

The index of the current computation.

source

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 the Clone trait and have a 'static lifetime.
Returns

An Option containing the value of the current path for the current device, if present.

source

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 the Clone trait and have a 'static lifetime.
Returns

An Option containing the value of the current path for the current neighbor, if present.

source

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.

source

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.

source

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 type A.
  • id - The id of the neighbor.. It is of type i32.
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 type A.
Returns

An Option containing the result of the expression.

source

pub fn nest_in(&mut self, slot: Slot)

source

pub fn nest_write<A: Copy + 'static>(&mut self, write: bool, value: A) -> A

source

pub fn nest_out(&mut self, inc: bool)

source

pub fn aligned_neighbours<A: 'static>(&self) -> Vec<i32>

Get a vector of aligned neighbor identifiers.

Returns

A vector of aligned neighbor identifiers.

source

pub fn isolate<A, F>(&mut self, expr: F) -> A
where 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 type A.
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 type A.
Returns

The result of the closure expr.

source

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.
source

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.

Trait Implementations§

source§

impl Clone for RoundVM

source§

fn clone(&self) -> RoundVM

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RoundVM

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for RoundVM

§

impl !Send for RoundVM

§

impl !Sync for RoundVM

§

impl Unpin for RoundVM

§

impl !UnwindSafe for RoundVM

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.