gantz_std 0.5.0

A standard library of commonly useful nodes for gantz, an environment for creative systems.
Documentation
use gantz_core::node::{EvalConf, ExprCtx, ExprResult, MetaCtx};
use gantz_nodetag::NodeTag;
use serde::{Deserialize, Serialize};

/// A simple node for pushing evaluation through the graph.
///
/// Exposes a single *trigger* input whose value is ignored: a push into it
/// emits a bang (`'()`) downstream. This lets a bang be fired from upstream as
/// well as from its button, normalising any value to a bang.
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Deserialize, Serialize, NodeTag)]
pub struct Bang;

impl gantz_core::Node for Bang {
    /// A single trigger input whose value is ignored.
    fn n_inputs(&self, _ctx: MetaCtx) -> usize {
        1
    }

    fn n_outputs(&self, _ctx: MetaCtx) -> usize {
        1
    }

    fn expr(&self, _ctx: ExprCtx<'_, '_>) -> ExprResult {
        gantz_core::node::parse_expr("'()")
    }

    fn push_eval(&self, _ctx: MetaCtx) -> Vec<EvalConf> {
        vec![EvalConf::All]
    }
}