bb_runtime/roles/data_source.rs
1//! `DataSourceRuntime` - role trait for data-source implementations.
2//!
3//! Per `docs/ROLES.md` §9. The trait carries the universal pair
4//! (`atomic_opset` + `dispatch_atomic`); the engine routes through
5//! `dispatch_atomic`. Author Contract impls
6//! (`crate::contracts::DataSource`) define the user-facing surface;
7//! `#[derive(bb::DataSource)]` emits the bridge into
8//! `DataSourceRuntime::dispatch_atomic`.
9
10use crate::atomic::{AtomicOpsetDecl, DispatchResult};
11use crate::runtime::RuntimeResourceRef;
12use crate::slot_value::SlotValue;
13
14/// Role trait for data-source implementations.
15pub trait DataSourceRuntime: Send + Sync {
16 /// Data-source-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}