pub trait ModuleBase {
Show 16 methods
// Required methods
fn describe(&self) -> Value;
fn command(&mut self, cmd: &str, args: Value) -> Result<Value, Error>;
fn read(&mut self, param: &str) -> Result<Value, Error>;
fn change(&mut self, param: &str, value: Value) -> Result<Value, Error>;
fn init_params(&mut self) -> Result<(), Error>;
fn activate_updates(&mut self) -> Vec<Msg>;
fn poll_normal(&mut self, n: usize);
fn poll_busy(&mut self, n: usize);
fn internals(&self) -> &ModInternals;
fn internals_mut(&mut self) -> &mut ModInternals;
// Provided methods
fn name(&self) -> &str { ... }
fn config(&self) -> &ModuleConfig { ... }
fn init_parameter<T: Clone + PartialEq>(
&mut self,
param: &str,
cached: impl Fn(&mut Self) -> &mut CachedParam<T>,
partype: &impl TypeDesc<Repr = T>,
update: impl Fn(&mut Self, T) -> Result<(), Error>,
swonly: bool,
readonly: bool,
default: Option<impl Fn() -> T>,
) -> Result<(), Error> { ... }
fn send_update(&self, param: &str, value: Value, tstamp: f64) { ... }
fn update_pollinterval(&mut self, val: f64) -> Result<(), Error> { ... }
fn run(self)
where Self: Sized + Module { ... }
}Expand description
Part of the Module trait that is implemented by the derive macro.
Required Methods§
Sourcefn read(&mut self, param: &str) -> Result<Value, Error>
fn read(&mut self, param: &str) -> Result<Value, Error>
Read a parameter and possibly emit an update message.
Sourcefn change(&mut self, param: &str, value: Value) -> Result<Value, Error>
fn change(&mut self, param: &str, value: Value) -> Result<Value, Error>
Change a parameter and possibly emit an update message.
Sourcefn init_params(&mut self) -> Result<(), Error>
fn init_params(&mut self) -> Result<(), Error>
Initialize cached values for all parameters.
Sourcefn activate_updates(&mut self) -> Vec<Msg>
fn activate_updates(&mut self) -> Vec<Msg>
Get a list of updates for all parameters, which must be sent upon activation of the module.
Sourcefn poll_normal(&mut self, n: usize)
fn poll_normal(&mut self, n: usize)
Poll parameters. If device is busy, parameters that participate in busy-poll are not polled.
Sourcefn poll_busy(&mut self, n: usize)
fn poll_busy(&mut self, n: usize)
Poll parameters that participate in busy-poll if device status is busy.
Sourcefn internals(&self) -> &ModInternals
fn internals(&self) -> &ModInternals
Return a reference to the module internals. Even though we require
the internals to be a member with a fixed name, the member is not
known in the run method below.
fn internals_mut(&mut self) -> &mut ModInternals
Provided Methods§
fn name(&self) -> &str
fn config(&self) -> &ModuleConfig
Sourcefn init_parameter<T: Clone + PartialEq>(
&mut self,
param: &str,
cached: impl Fn(&mut Self) -> &mut CachedParam<T>,
partype: &impl TypeDesc<Repr = T>,
update: impl Fn(&mut Self, T) -> Result<(), Error>,
swonly: bool,
readonly: bool,
default: Option<impl Fn() -> T>,
) -> Result<(), Error>
fn init_parameter<T: Clone + PartialEq>( &mut self, param: &str, cached: impl Fn(&mut Self) -> &mut CachedParam<T>, partype: &impl TypeDesc<Repr = T>, update: impl Fn(&mut Self, T) -> Result<(), Error>, swonly: bool, readonly: bool, default: Option<impl Fn() -> T>, ) -> Result<(), Error>
Determine and set the initial value for a parameter.
This is quite complex since we have multiple sources (defaults from code, config file, hardware) and multiple ways of using them (depending on whether the parameter is writable at runtime).
Sourcefn send_update(&self, param: &str, value: Value, tstamp: f64)
fn send_update(&self, param: &str, value: Value, tstamp: f64)
Send a general update message back to the dispatcher, which decides if and where to send it on.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.