pub trait DevicePlugin:
Send
+ Sync
+ 'static {
// Required methods
fn kind(&self) -> &'static str;
fn config_schema(&self) -> Schema;
fn faults(&self) -> Vec<FaultId>;
fn create(
&self,
id: DeviceId,
config: Value,
) -> Result<Box<dyn Device>, ConfigError>;
}Expand description
A device type that can be instantiated from JSON config, e.g. printer-escpos.
Register plugins with Registry::register.
Required Methods§
Sourcefn config_schema(&self) -> Schema
fn config_schema(&self) -> Schema
JSON Schema for the config accepted by DevicePlugin::create.
Sourcefn faults(&self) -> Vec<FaultId>
fn faults(&self) -> Vec<FaultId>
Every fault a device of this kind can support, e.g. for listing faults by kind. A
particular instance may support fewer, see Device::faults.
Sourcefn create(
&self,
id: DeviceId,
config: Value,
) -> Result<Box<dyn Device>, ConfigError>
fn create( &self, id: DeviceId, config: Value, ) -> Result<Box<dyn Device>, ConfigError>
Creates a device instance. Invalid config is a ConfigError, never a panic.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".