Skip to main content

Executor

Struct Executor 

Source
pub struct Executor {
    pub plugin: Plugin,
    pub rx: Receiver,
    pub tx: Transmitter,
    /* private fields */
}
Expand description

Executes tasks on a Plugin in response to messages.

Each Plugin is powered by a single executor.

Fields§

§plugin: Plugin

The Plugin instance that is managed by this executor.

§rx: Receiver

The executor’s receiver.

§tx: Transmitter

The executor’s transmitter.

Implementations§

Source§

impl Executor

Source

pub fn new(plugin: Plugin) -> Executor

Returns a new instance of an executor.

§Arguments
  • plugin - The Plugin instance that is managed by this Executor
Source

pub fn run(self, peripheral: Peripheral)

Starts an Executor.

The Executor runs inside an infinite loop. During one iteration of the loop, it checks for a new message in its message queue. If found, it processes the message (possibly by communicating with the peripheral through the plugin interface) and returns the result via the return transmitter that was passed alongside the message.

§Arguments
  • peripheral - The instance of a peripheral model that is used to return responses to the request handlers
Source

pub fn attribute_count(&self) -> Result<usize, ExecutorError>

Returns the number of attributes of a Plugin.

Source

pub fn attribute_ids(&self) -> Result<Vec<usize>, ExecutorError>

Returns the set of attribute IDs of a Plugin.

Source

pub fn attribute_name(&self, id: size_t) -> Result<String, ExecutorError>

Returns the name of an attribute from a Plugin.

§Arguments
  • id - The attribute’s unique ID
Source

pub fn attribute_pre_init(&self, id: size_t) -> Result<bool, ExecutorError>

Determines whether an attribute may be set before initialization.

§Arguments
  • id - The attribute’s unique ID
Source

pub fn attribute_value( &self, id: size_t, value: &mut Val, ) -> Result<(), ExecutorError>

Returns the value of an attribute from a Plugin.

§Arguments
  • id - The attribute’s unique ID
  • value - A reference to a value instance into which the attribute’s value will be copied
Source

pub fn set_attribute_value( &self, id: size_t, value: &Val, ) -> Result<(), ExecutorError>

Sets the value of an attribute of a Plugin.

§Arguments
  • id - The attribute’s unique ID
  • value - A reference to a value instance that will be copied into the plugin
  • phase - The lifecycle phase of the plugin that determines which callbacks to use
Source

pub fn advance(&mut self) -> Result<i32, ExecutorError>

Advances the plugin to the next lifecycle phase.

Source

pub fn discover_attributes(&mut self) -> Option<BTreeMap<usize, Attribute>>

Gets all attribute values and names from a Plugin and updates the corresponding Peripheral.

This method is only called once to discover the attributes of the plugin.

Source

pub fn init(&self) -> Result<(), ExecutorError>

Initializes the plugin.

Source

pub fn sync(&mut self, peripheral: &Peripheral) -> Result<(), ExecutorError>

Synchronizes the plugin with the peripheral model by setting all settable attributes.

§Arguments
  • peripheral - A reference to peripheral data to which the plugin will be synchronized

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.