use crate::node::{self, Node};
use gantz_ca::CaHash;
use gantz_nodetag::NodeTag;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize, CaHash, NodeTag)]
#[cahash("gantz.delay")]
pub struct Delay;
impl Node for Delay {
fn expr(&self, _ctx: node::ExprCtx<'_, '_>) -> node::ExprResult {
node::parse_expr("'()")
}
fn n_inputs(&self, _ctx: node::MetaCtx) -> usize {
1
}
fn n_outputs(&self, _ctx: node::MetaCtx) -> usize {
1
}
fn delay(&self, _ctx: node::MetaCtx) -> bool {
true
}
fn stateful(&self, _ctx: node::MetaCtx) -> bool {
true
}
fn register(&self, ctx: node::RegCtx<'_, '_>) {
let (_, path, vm) = ctx.into_parts();
node::state::init_value_if_absent(vm, path, || steel::SteelVal::ListV(Default::default()))
.unwrap();
}
}