Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Param

Param<T> is a read-only dataset wrapper for configuration values. It is the primary way to pass parameters into pipeline nodes.

Definition

#[derive(Debug, Serialize, Deserialize)]
pub struct Param<T: Clone>(pub T);

impl<T: Clone + Serialize> Dataset for Param<T> {
    type LoadItem = T;
    type SaveItem = Never;   // uninhabited
    type Error = PondError;

    fn load(&self) -> Result<T, PondError> { Ok(self.0.clone()) }
    fn save(&self, output: Never) -> Result<(), PondError> { match output {} }
    fn is_param(&self) -> bool { true }
}

Key properties:

  • Loading always succeedsload() never returns Err. The declared Error is PondError rather than Infallible: a node’s input tuple requires E: From<D::Error> of every slot, and a Param appears in nearly every pipeline, so Infallible would make every user error type owe a From<Infallible> impl
  • Writing is forbidden at compile timeSaveItem is Never, an uninhabited type. A node whose output tuple contains a &Param<T> does not compile, because its function would have to produce a value that cannot exist. save() discharges its argument with match output {} — no runtime code, no panic
  • is_param() returns true — used by the validator and visualization to distinguish params from data

Usage

#[derive(Serialize, Deserialize)]
struct Params {
    threshold: Param<f64>,
    max_retries: Param<u32>,
}

Node {
    name: "filter",
    input: (&cat.value, &params.threshold),
    output: (&cat.passed,),
    func: |value: f64, threshold: f64| {
        (value >= threshold,)
    },
}

YAML

threshold: 0.5
max_retries: 3

Param<T> deserializes directly from the YAML value — no wrapping object needed.

Visualization

In the viz dashboard, parameters appear as distinct node shapes, separate from datasets. They are also shown in the left panel’s “Parameters” section.

no_std

Param is available in no_std — it requires no feature flags and uses no allocation.