bb_ops/syscalls/composite/
bundle.rs1use bb_ir::proto::onnx::NodeProto;
12use bb_runtime::atomic::DispatchResult;
13use bb_runtime::bus::{OpError, OpErrorKind};
14use bb_runtime::runtime::RuntimeResourceRef;
15use bb_runtime::slot_value::SlotValue;
16use bb_runtime::syscall::values::CompositeValue;
17
18pub const DOMAIN: &str = "ai.bytesandbrains.composite";
21pub const OP_TYPE: &str = "Bundle";
23pub const PORT_BUNDLE: &str = "bundle";
25
26pub fn invoke(
32 _node: &NodeProto,
33 inputs: &[(&str, &dyn SlotValue)],
34 _ctx: &mut RuntimeResourceRef<'_>,
35) -> Result<DispatchResult, OpError> {
36 if inputs.is_empty() {
37 return Err(OpError {
38 kind: OpErrorKind::MissingSlot,
39 reason: "bundle_no_children",
40 detail: "composite.Bundle: at least one child input required".into(),
41 });
42 }
43 let mut children: Vec<Box<dyn SlotValue>> = Vec::with_capacity(inputs.len());
44 for (_slot_name, value) in inputs {
45 children.push(value.clone_boxed());
46 }
47 Ok(DispatchResult::Immediate(vec![(
48 PORT_BUNDLE.to_string(),
49 Box::new(CompositeValue { children }) as Box<dyn SlotValue>,
50 )]))
51}
52
53
54bb_derive::register_op! {
55 domain: "ai.bytesandbrains.composite",
56 op_type: "Bundle",
57 invoke: invoke,
58}