Skip to main content

bb_dsl/
output.rs

1//! Non-generic `Output` handle threaded through DSL method chains.
2//!
3//! Per `docs/API_DESIGN.md` §4 + `docs/IR_AND_DSL.md` Part 6. The DSL
4//! is non-generic across languages - type metadata rides on
5//! `&'static TypeNode`, NOT a `PhantomData<T>` tag. Identity is the
6//! `name: String` (the ONNX value name in `FunctionProto.input` /
7//! `NodeProto.input` / `NodeProto.output`); the wire-level type
8//! identity rides on the `TypeNode` reference.
9
10use bb_ir::types::TypeNode;
11
12/// Handle passed between DSL methods. Carries the recorded ONNX
13/// value name plus a `&'static` pointer to the canonical
14/// [`TypeNode`] of the value's type.
15#[derive(Clone, Debug)]
16pub struct Output {
17    /// ONNX value name. Matches a `FunctionProto.input` entry, a
18    /// `NodeProto.output` entry, or a `next_site_name()` mint.
19    pub name: String,
20
21    /// Static `TypeNode` reference. Pointer equality is meaningful
22    /// - every canonical type lives in a single `static`.
23    pub type_node: &'static TypeNode,
24}
25
26impl Output {
27    /// Construct an `Output` handle from a value name + canonical
28    /// type metadata.
29    pub fn new(name: String, type_node: &'static TypeNode) -> Self {
30        Self { name, type_node }
31    }
32}
33