use core_types::ExtractAll; use core_types::runtime::SourceFuture; use core_types::{Ctx, ops::Convert, ops::ConvertAsync, transform::Footprint}; use std::marker::PhantomData; /// Passes-through the input value without changing it. This is useful for rerouting wires for organization purposes. #[node_macro::node(category("General"), skip_impl)] fn passthrough(_: impl Ctx, content: T) -> T { content } #[node_macro::node(category(""), skip_impl)] fn into, O: Send>(_: impl Ctx, value: T, #[data] _out_ty: PhantomData) -> O { value.into() } #[node_macro::node(category(""), skip_impl)] fn convert, O: Send, C: Send>(ctx: impl Ctx + ExtractAll, value: T, converter: C, #[data] _out_ty: PhantomData) -> O { value.convert(*ctx.try_footprint().unwrap_or(&Footprint::DEFAULT), converter) } #[node_macro::node(category(""), skip_impl)] fn convert_async, O: Send + 'static, C: Send>(ctx: impl Ctx + ExtractAll, value: T, converter: C, #[data] _out_ty: PhantomData) -> SourceFuture { value.convert(*ctx.try_footprint().unwrap_or(&Footprint::DEFAULT), converter) } #[cfg(test)] mod test { use super::*; #[test] pub fn passthrough_node() { assert_eq!(passthrough(&(), &4), &4); } }