Skip to content

v0.25.3

Choose a tag to compare

@flowzone-app flowzone-app released this 19 Feb 18:13
08e0986

Add SystemTarget extractor

  • Adds SystemTarget<T> extractor that provides access to the full target state passed to the worker, as opposed to Target<T> which resolves to the value
    at the task's scoped path

    • The global target is now automatically propagated to child tasks in methods, so .with_target() is no longer needed when forwarding the same target
    • Adds target_override to Context to distinguish between the global target and an explicit override via with_target()

    Example

    SystemTarget is useful when a task scoped to a sub-path needs to inspect the full target state:

    use mahler::state::{State, Map};
    use mahler::extract::{View, Target, SystemTarget};
    use mahler::task::IO;
    
    #[derive(State)]
    struct App {
        services: Map<String, Service>,
    }
    
    #[derive(State)]
    struct Service {
        image: String,
        running: bool,
    }
    
    // This task is scoped to a single service via "/{service}"
    // `Target` gives the target for this specific service
    // `SystemTarget` gives the full App target
    fn start_service(
        mut svc: View<Service>,
        Target(tgt): Target<Service>,
        SystemTarget(app_tgt): SystemTarget<App>,
    ) {
        // Use the scoped target for this service
        svc.running = tgt.running;
    
        // Use the system target to check other services,
        // e.g. to coordinate dependencies across services
        let total_services = app_tgt.services.len();
        // ...
    }

  Methods no longer need .with_target() to forward the target to child tasks:

```rust
  // Before
  fn my_method(Target(tgt): Target<i32>) -> Vec<Task> {
      vec![child_task.with_target(tgt)]
  }

  // After - global target is propagated automatically
  fn my_method() -> Vec<Task> {
      vec![child_task.into_task()]
  }

List of commits

a2f3b8a (Add SystemTarget extractor, 2026-02-18)