bb_ops/syscalls/triggers/
on_trigger.rs1use bb_ir::proto::onnx::NodeProto;
4use bb_runtime::atomic::DispatchResult;
5use bb_runtime::bus::OpError;
6use bb_runtime::runtime::RuntimeResourceRef;
7use bb_runtime::slot_value::SlotValue;
8use bb_runtime::syscall::values::TriggerValue;
9
10pub struct OnTriggerOp;
12
13pub const DOMAIN: &str = "ai.bytesandbrains.syscall";
15pub const OP_TYPE: &str = "OnTrigger";
17
18pub fn invoke(
20 _node: &NodeProto,
21 inputs: &[(&str, &dyn SlotValue)],
22 _ctx: &mut RuntimeResourceRef<'_>,
23) -> Result<DispatchResult, OpError> {
24 if inputs.is_empty() {
25 return Err(OpError {
26 detail: "OnTrigger requires one input".to_string(),
27 ..Default::default()
28 });
29 }
30 Ok(DispatchResult::Immediate(vec![(
31 "trigger".to_string(),
32 Box::new(TriggerValue),
33 )]))
34}
35
36use bb_runtime::registry::OpRegistration as _BbOpsSyscallReg;
37
38inventory::submit! {
39 _BbOpsSyscallReg {
40 domain: DOMAIN,
41 op_type: OP_TYPE,
42 invoke,
43 kind: bb_runtime::registry::RegistrationKind::Syscall,
44 }
45}