daedalus_nodes/
bundle_demo.rs1use crate::declare_plugin;
4use daedalus_macros::node;
5use daedalus_runtime::NodeError;
6use daedalus_runtime::handler_registry::HandlerRegistry;
7use daedalus_runtime::plugins::PluginRegistry;
8
9#[derive(Clone, Debug, serde::Deserialize)]
10pub struct Frame {
11 pub bytes: Vec<u8>,
12}
13
14#[derive(Clone, Debug, serde::Deserialize)]
15pub struct Detection {
16 pub id: i32,
17}
18
19declare_plugin!(DemoPlugin, "demo", [frame_src, decode, sink]);
20
21pub fn install_bundle(registry: &mut PluginRegistry) -> Result<HandlerRegistry, &'static str> {
23 registry.merge::<frame_src>()?;
24 registry.merge::<decode>()?;
25 registry.merge::<sink>()?;
26 Ok(registry.take_handlers())
27}
28
29#[node(id = "demo:frame_src", bundle = "demo", outputs("frame"))]
30fn frame_src() -> Result<Frame, NodeError> {
31 Ok(Frame {
32 bytes: b"frame".to_vec(),
33 })
34}
35
36#[node(
37 id = "demo:decode",
38 bundle = "demo",
39 inputs("frame"),
40 outputs("detections")
41)]
42fn decode(frame: Frame) -> Result<Vec<Detection>, NodeError> {
43 Ok(vec![Detection {
44 id: frame.bytes.len() as i32,
45 }])
46}
47
48#[node(id = "demo:sink", bundle = "demo", inputs("detections"))]
49fn sink(detections: Vec<Detection>) -> Result<(), NodeError> {
50 println!("demo detections: {:?}", detections);
51 Ok(())
52}