pub trait TaskModule: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn register(&self, registry: &mut TaskRegistry) -> RustvelloResult<()>;
}Expand description
A module that registers one or more tasks with a TaskRegistry.
Inspired by pynenc’s plugin system — each module groups related tasks and registers them at application startup.
§Example
use rustvello_core::task::{TaskModule, TaskRegistry, TaskDefinition};
use rustvello_proto::config::TaskConfig;
use rustvello_proto::identifiers::TaskId;
use rustvello_core::error::RustvelloResult;
use std::sync::Arc;
struct MathTasks;
impl TaskModule for MathTasks {
fn name(&self) -> &str { "math" }
fn register(&self, registry: &mut TaskRegistry) -> RustvelloResult<()> {
registry.register(TaskDefinition::new(
TaskId::new("math", "add"),
TaskConfig::default(),
Arc::new(|_| Ok("0".to_string())),
))
}
}Required Methods§
Sourcefn register(&self, registry: &mut TaskRegistry) -> RustvelloResult<()>
fn register(&self, registry: &mut TaskRegistry) -> RustvelloResult<()>
Register all tasks provided by this module.