Expand description
Generic daemon framework traits and runner
Provides a structured way to implement daemon-based plugins with minimal boilerplate.
§Example
ⓘ
use taiga_plugin_api::daemon::traits::{DaemonHandler, DaemonConfig, run_daemon_loop};
use async_trait::async_trait;
struct MyDaemon {
counter: u32,
}
#[async_trait]
impl DaemonHandler for MyDaemon {
type Command = MyCommand;
type Response = MyResponse;
async fn handle_command(&mut self, cmd: Self::Command) -> Self::Response {
match cmd {
MyCommand::Increment => {
self.counter += 1;
MyResponse::Ok(self.counter)
}
}
}
async fn on_tick(&mut self) {
// Called periodically
}
}
// In your daemon entry point:
let config = DaemonConfig::new("/tmp/my-plugin.sock");
run_daemon_loop(config, MyDaemon { counter: 0 }).await?;Structs§
- Daemon
Config - Configuration for running a daemon
Enums§
- Handle
Result - Result of handling a command
Traits§
- Daemon
Handler - Trait for implementing daemon command handlers
Functions§
- run_
daemon_ loop - Run the daemon event loop