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: PluginThe Plugin instance that is managed by this executor.
rx: ReceiverThe executor’s receiver.
tx: TransmitterThe executor’s transmitter.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn new(plugin: Plugin) -> Executor
pub fn new(plugin: Plugin) -> Executor
Returns a new instance of an executor.
§Arguments
plugin- The Plugin instance that is managed by this Executor
Sourcepub fn run(self, peripheral: Peripheral)
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
Sourcepub fn attribute_count(&self) -> Result<usize, ExecutorError>
pub fn attribute_count(&self) -> Result<usize, ExecutorError>
Returns the number of attributes of a Plugin.
Sourcepub fn attribute_ids(&self) -> Result<Vec<usize>, ExecutorError>
pub fn attribute_ids(&self) -> Result<Vec<usize>, ExecutorError>
Returns the set of attribute IDs of a Plugin.
Sourcepub fn attribute_name(&self, id: size_t) -> Result<String, ExecutorError>
pub fn attribute_name(&self, id: size_t) -> Result<String, ExecutorError>
Sourcepub fn attribute_pre_init(&self, id: size_t) -> Result<bool, ExecutorError>
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
Sourcepub fn attribute_value(
&self,
id: size_t,
value: &mut Val,
) -> Result<(), ExecutorError>
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 IDvalue- A reference to a value instance into which the attribute’s value will be copied
Sourcepub fn set_attribute_value(
&self,
id: size_t,
value: &Val,
) -> Result<(), ExecutorError>
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 IDvalue- A reference to a value instance that will be copied into the pluginphase- The lifecycle phase of the plugin that determines which callbacks to use
Sourcepub fn advance(&mut self) -> Result<i32, ExecutorError>
pub fn advance(&mut self) -> Result<i32, ExecutorError>
Advances the plugin to the next lifecycle phase.