pub trait Plugin: Sized {
type Config: DeserializeOwned + JsonSchema;
type SystemConfig: DeserializeOwned + JsonSchema;
// Required methods
fn manifest() -> Manifest;
fn start(
host: Host,
setup: Setup<Self::Config, Self::SystemConfig>,
) -> Result<Self, String>;
// Provided methods
fn call_start(&mut self, _call: CallInfo) { ... }
fn call_end(&mut self, _call: CallInfo) { ... }
fn call_concluded(&mut self, _call: ConcludedCall) { ... }
fn unit(&mut self, _event: UnitEvent) { ... }
fn audio(&mut self, _chunk: AudioChunk) { ... }
fn status(&mut self, _status: Status) { ... }
fn tone_pattern(&mut self, _t: TonePatternEvent) { ... }
fn action(&mut self, _a: Action, reply: Reply) { ... }
fn settings(
&mut self,
_setup: Setup<Self::Config, Self::SystemConfig>,
) -> Result<(), String> { ... }
fn shutdown(&mut self, _grace: Duration) { ... }
}Expand description
A plugin. Every method runs on the one thread that reads the recorder’s messages, one message at a time: return quickly, and hand slow work (network, disk, other processes) to a thread of your own.
Required Associated Types§
Sourcetype Config: DeserializeOwned + JsonSchema
type Config: DeserializeOwned + JsonSchema
The plugin’s settings. #[serde(default)] on the struct lets a user
leave any of them empty. The settings form is drawn from its schema
(see crate::schema). NoConfig for none. A system can override
any of them (another server for it, say): read them for a system from
System::settings, and from Setup::config only for what isn’t
any one system’s.
Sourcetype SystemConfig: DeserializeOwned + JsonSchema
type SystemConfig: DeserializeOwned + JsonSchema
Settings for each system, when the plugin needs some (an API key per
system, say). NoConfig for none.
Required Methods§
Sourcefn manifest() -> Manifest
fn manifest() -> Manifest
Who the plugin is and what it subscribes to — start from crate::manifest!.
config and system_config are filled in from the types above.
Provided Methods§
fn call_start(&mut self, _call: CallInfo)
fn call_end(&mut self, _call: CallInfo)
fn call_concluded(&mut self, _call: ConcludedCall)
fn unit(&mut self, _event: UnitEvent)
fn audio(&mut self, _chunk: AudioChunk)
fn status(&mut self, _status: Status)
Sourcefn tone_pattern(&mut self, _t: TonePatternEvent)
fn tone_pattern(&mut self, _t: TonePatternEvent)
A call’s tones made a pattern: every one heard (subscribe to tone_pattern).
Sourcefn action(&mut self, _a: Action, reply: Reply)
fn action(&mut self, _a: Action, reply: Reply)
One of the plugin’s buttons was pressed (x-actions in its settings
schema). Answer through reply, now or from another thread once the
work is done; a reply dropped unsent answers that it failed.
Sourcefn settings(
&mut self,
_setup: Setup<Self::Config, Self::SystemConfig>,
) -> Result<(), String>
fn settings( &mut self, _setup: Setup<Self::Config, Self::SystemConfig>, ) -> Result<(), String>
Its settings changed while it runs (set Manifest::live_settings
for this to be called rather than the plugin restarted). An Err is
shown as its status, and the settings it had stay.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".