bb_runtime/roles/aggregator.rs
1//! `AggregatorRuntime` - role trait for aggregator implementations.
2//!
3//! Per `docs/ROLES.md` §7. The trait carries the universal pair
4//! (`atomic_opset` + `dispatch_atomic`); the engine routes through
5//! `dispatch_atomic`. Author Contract impls
6//! (`crate::contracts::Aggregator`) define the user-facing surface;
7//! `#[derive(bb::Aggregator)]` emits the bridge into
8//! `AggregatorRuntime::dispatch_atomic`.
9
10use crate::atomic::{AtomicOpsetDecl, DispatchResult};
11use crate::runtime::RuntimeResourceRef;
12use crate::slot_value::SlotValue;
13
14/// Role trait for aggregator implementations.
15pub trait AggregatorRuntime: Send + Sync {
16 /// Aggregator-impl-specific error type.
17 type Error: std::error::Error + Send + Sync + 'static;
18
19 /// Atomic-op opset this impl owns.
20 fn atomic_opset(&self) -> AtomicOpsetDecl;
21
22 /// Rust-dispatch entry point for atomic ops.
23 fn dispatch_atomic(
24 &mut self,
25 op_type: &str,
26 inputs: &[(&str, &dyn SlotValue)],
27 ctx: &mut RuntimeResourceRef<'_>,
28 ) -> Result<DispatchResult, Self::Error>;
29}