Module traits

Module traits 

Source
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§

DaemonConfig
Configuration for running a daemon

Enums§

HandleResult
Result of handling a command

Traits§

DaemonHandler
Trait for implementing daemon command handlers

Functions§

run_daemon_loop
Run the daemon event loop