Expand description
Plugins for Trunk Recorder Pro.
A plugin is a program of its own that the recorder starts, sends events to
(calls starting, ending and landing on disk; radios registering; live
audio; status) and stops. It only watches: nothing it does changes what is
recorded. The protocol is JSON lines over stdin/stdout, so a plugin
can be written in anything; this crate is the Rust side of it.
use trunk_recorder_plugin::{topic, ConcludedCall, Host, Manifest, NoConfig, Plugin, Setup};
struct Hello { host: Host }
impl Plugin for Hello {
type Config = NoConfig;
type SystemConfig = NoConfig;
fn manifest() -> Manifest {
Manifest { name: "Hello".into(), subscribe: vec![topic::CALL_CONCLUDED.into()], ..trunk_recorder_plugin::manifest!() }
}
fn start(host: Host, _: Setup<NoConfig, NoConfig>) -> Result<Self, String> {
Ok(Hello { host })
}
fn call_concluded(&mut self, call: ConcludedCall) {
self.host.info(format!("TG {} for {} s", call.call.talkgroup, call.call.call_length));
}
}
fn main() {
trunk_recorder_plugin::run::<Hello>();
}Re-exports§
pub use filter::TalkgroupFilter;pub use crate::schema::NoConfig;pub use protocol::*;
Modules§
- filter
- Talkgroup allow and deny lists, as Trunk Recorder’s uploaders take them:
patterns matched against the talkgroup number written out (
"507*","12?45","8001"), where*is any run of characters and?any one. - protocol
- The wire protocol: JSON lines.
- schema
- Settings schemas: a config struct’s JSON Schema (from
schemars), reduced to the subset the recorder’s settings form draws. - testing
- Testing a plugin without the recorder: feed it messages, look at what it says back.
Macros§
- manifest
- A manifest with the id, version, description, homepage, repository, authors and license from Cargo.toml; the name is the id until you set one:
Structs§
- Call
Queue - Host
- The way back to the recorder: logs, health, results. Cheap to clone and
usable from any thread. (A plugin’s stdout belongs to the protocol — never
println!in a plugin; use this, oreprintln!for the raw log.) - Multipart
- Queue
Options - Setup
- What
Plugin::startgets. - System
Enums§
- Attempt
- What became of one try at a call.
Traits§
- Plugin
- 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.