Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }
Expand description

Recording context every DSL method writes into.

Implementations§

Source§

impl Graph

Source

pub fn new() -> Self

Empty Graph. Module::build() wraps the body in with_function(self.name(), ...) automatically.

Source

pub fn take_pending_errors(&mut self) -> Vec<BuildError>

Drain accumulated recorder errors.

Source

pub fn output(&mut self, name: &str, handle: Output)

Register a named output port. Idempotent — a second call for the same (target_idx, name) returns the prior handle.

Source

pub fn net_out(&mut self, name: &str, peers: Output, value: Output)

Emit a wire.Send to peers (a Vec<PeerId> at dispatch) and register name as a network output. The compiler’s partition_by_wire_ops cuts here; synthesize_wire_recvs materializes the matching wire.Recv.

Source

pub fn bundle(&mut self, parts: &[Output]) -> Output

Pack N typed Outputs into one composite. Receiver pairs with Self::unbundle. Composite envelope is bb_ir::types::TYPE_COMPOSITE. Panics on empty parts.

Source

pub fn unbundle( &mut self, composite: Output, part_types: &[&'static TypeNode], ) -> Vec<Output>

Extract a composite Output back into its N child Outputs. part_types declares the expected child TypeNodes positionally; the runtime op validates the envelope’s child count against the declared length and emits one BytesValue-shaped output per child, named child_{i} and typed against part_types[i] via the stamped ValueInfoProto.denotation. Downstream consumers decode against that denotation, matching the wire.Recv pattern.

Panics with a recording-time error if part_types is empty — the matching g.bundle cannot have produced a zero-child envelope.

Source

pub fn lookup_output(&self, name: &str) -> Option<Output>

Look up a previously-registered output port by name on the current recording target. Returns None when neither output(name, ...) nor an enclosing scope has registered the port — callers report BuildError::MissingOutputPort.

Source

pub fn record_build_error(&mut self, err: BuildError)

Push a crate::module::BuildError onto the recorder’s pending-errors queue. Used by methods that must keep their existing return shape (e.g. Graph::wire returns the typed output triple) but want a typed-error escape from a panic.

Source

pub fn finish(self) -> RecordedModule

Extract the recorded function body for the compiler to consume. Called by Module::build() after module.op() returns. The chosen-path install constructs concrete instances via the inventory’s construct_fn at install time; the IR carries no instance state.

Source

pub fn register_generic<T: 'static>( &mut self, instance: &T, _required_trait: &'static str, ) -> u32

Pointer-identity-keyed slot allocation for generic placeholders. Appends "__slot_<slot_id>" to FunctionProto.attribute on first encounter.

Source

pub fn input(&mut self, name: &str) -> Output

Declare a Module input by name. Lands with bb_ir::types::TYPE_BYTES sentinel; the TypeSolver narrows it later. Propagates up the recording-target chain in Open mode so enclosing CALL NodeProtos stay referenceable.

Source

pub fn next_site_name(&mut self) -> String

Allocate a fresh value-name. Monotonic counter; format "v<n>".

Source

pub fn declare_value_info(&mut self, name: &str, type_node: &'static TypeNode)

Stamp a ValueInfoProto for name on the current target. Idempotent. Recorders call this on every minted output.

Source

pub fn push_node(&mut self, node: NodeProto)

Push a NodeProto into the active target. Stamps MODULE_INSTANCE_KEY with the joined with_function chain; an existing stamp is prefixed (preserves replayed hierarchy).

Source

pub fn with_function<F>( &mut self, name: &str, bindings: &[(String, Output)], body: F, ) -> Vec<(String, String)>
where F: FnOnce(&mut Graph),

Record body into a sub-FunctionProto named name and emit a CALL in the outer target. Top-level wraps fold the body into function[0] instead of synthesizing a CALL.

bindings pre-loads formal→actual handles so g.input(formal) inside body returns the actual.

Returns (child_port_name, parent_call_output_name) pairs for non-top-level wraps; empty for top-level (g.output registers directly in the parent scope).

Source

pub fn function(&self) -> &FunctionProto

Read-only view of the recorded FunctionProto. ’s compiler + the acceptance tests read everything from here - the proto is the single source of truth.

Trait Implementations§

Source§

impl Default for Graph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Send for Graph

§

impl !Sync for Graph

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more