Skip to main content

Node

Trait Node 

Source
pub trait Node<const IN: usize, const OUT: usize, InP, OutP>
where InP: Payload, OutP: Payload,
{
Show 13 methods // Required methods fn describe_capabilities(&self) -> NodeCapabilities; fn input_acceptance(&self) -> [PlacementAcceptance; IN]; fn output_acceptance(&self) -> [PlacementAcceptance; OUT]; fn policy(&self) -> NodePolicy; fn set_policy(&mut self, policy: NodePolicy); fn node_kind(&self) -> NodeKind; fn initialize<C, Tel>( &mut self, clock: &C, telemetry: &mut Tel, ) -> Result<(), NodeError> where Tel: Telemetry; fn start<C, Tel>( &mut self, _clock: &C, _telemetry: &mut Tel, ) -> Result<(), NodeError> where Tel: Telemetry; fn process_message<C>( &mut self, msg: &Message<InP>, sys_clock: &C, ) -> Result<ProcessResult<OutP>, NodeError> where C: PlatformClock + Sized; fn on_watchdog_timeout<C, Tel>( &mut self, _clock: &C, _telemetry: &mut Tel, ) -> Result<StepResult, NodeError> where C: PlatformClock + Sized, Tel: Telemetry; fn stop<C, Tel>( &mut self, _clock: &C, _telemetry: &mut Tel, ) -> Result<(), NodeError> where Tel: Telemetry; // Provided methods fn step<'graph, 'telemetry, 'clock, InQ, OutQ, InM, OutM, C, Tel>( &mut self, ctx: &mut StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>, ) -> Result<StepResult, NodeError> where InQ: Edge, OutQ: Edge, InM: MemoryManager<InP>, OutM: MemoryManager<OutP>, C: PlatformClock + Sized, Tel: Telemetry + Sized { ... } fn step_batch<'graph, 'telemetry, 'clock, InQ, OutQ, InM, OutM, C, Tel>( &mut self, ctx: &mut StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>, ) -> Result<StepResult, NodeError> where InQ: Edge, OutQ: Edge, InM: MemoryManager<InP>, OutM: MemoryManager<OutP>, C: PlatformClock + Sized, Tel: Telemetry + Sized { ... }
}
Expand description

The uniform node contract.

Nodes are parameterized by:

  • IN: number of input ports; OUT: number of output ports;
  • InP: input payload type; OutP: output payload type.

Queue and manager types are introduced on each method via where clauses rather than on the trait itself, keeping the trait payload-focused and avoiding an explosion of type parameters on the impl.

Required Methods§

Source

fn describe_capabilities(&self) -> NodeCapabilities

Return the node’s capability descriptor.

Source

fn input_acceptance(&self) -> [PlacementAcceptance; IN]

Return the node’s port placement acceptances (zero-copy compatibility).

Source

fn output_acceptance(&self) -> [PlacementAcceptance; OUT]

Return the node’s output placement preferences (zero-copy compatibility).

Source

fn policy(&self) -> NodePolicy

Return the node’s policy bundle.

Source

fn set_policy(&mut self, policy: NodePolicy)

TEST ONLY method used to override batching policies for node contract tests.

Source

fn node_kind(&self) -> NodeKind

Return the type of node (Model, processing, source, sink).

Source

fn initialize<C, Tel>( &mut self, clock: &C, telemetry: &mut Tel, ) -> Result<(), NodeError>
where Tel: Telemetry,

Prepare internal state, acquire buffers, and register telemetry series.

Source

fn start<C, Tel>( &mut self, _clock: &C, _telemetry: &mut Tel, ) -> Result<(), NodeError>
where Tel: Telemetry,

Optional warm-up (e.g., compile kernels, prime pools). Default: no-op.

Source

fn process_message<C>( &mut self, msg: &Message<InP>, sys_clock: &C, ) -> Result<ProcessResult<OutP>, NodeError>
where C: PlatformClock + Sized,

Per-message processing hook.

Receives a shared reference to the input message and returns a ProcessResult indicating what output (if any) was produced. The framework handles pushing outputs to edges; the node never interacts with queues or managers directly.

Source

fn on_watchdog_timeout<C, Tel>( &mut self, _clock: &C, _telemetry: &mut Tel, ) -> Result<StepResult, NodeError>
where C: PlatformClock + Sized, Tel: Telemetry,

Handle watchdog timeouts by applying over-budget policy (degrade/default/skip).

Source

fn stop<C, Tel>( &mut self, _clock: &C, _telemetry: &mut Tel, ) -> Result<(), NodeError>
where Tel: Telemetry,

Flush and release resources, if any. Default: no-op.

Provided Methods§

Source

fn step<'graph, 'telemetry, 'clock, InQ, OutQ, InM, OutM, C, Tel>( &mut self, ctx: &mut StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>, ) -> Result<StepResult, NodeError>
where InQ: Edge, OutQ: Edge, InM: MemoryManager<InP>, OutM: MemoryManager<OutP>, C: PlatformClock + Sized, Tel: Telemetry + Sized,

Execute one cooperative step using the provided context.

The default implementation:

  1. Finds a ready input port via input_edge_has_batch.
  2. Pops a single message via pop_and_process.
  3. Delegates to process_message inside the callback.
Source

fn step_batch<'graph, 'telemetry, 'clock, InQ, OutQ, InM, OutM, C, Tel>( &mut self, ctx: &mut StepContext<'graph, 'telemetry, 'clock, IN, OUT, InP, OutP, InQ, OutQ, InM, OutM, C, Tel>, ) -> Result<StepResult, NodeError>
where InQ: Edge, OutQ: Edge, InM: MemoryManager<InP>, OutM: MemoryManager<OutP>, C: PlatformClock + Sized, Tel: Telemetry + Sized,

Default batched-step implementation that honors all NodePolicy batching variants while delegating actual consumption to the implementor’s single-message process_message() method.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<B, InP, OutP, const MAX_BATCH: usize> Node<1, 1, InP, OutP> for InferenceModel<B, InP, OutP, MAX_BATCH>
where B: ComputeBackend<InP, OutP>, InP: Payload + Default + Copy, OutP: Payload + Default + Copy,

Source§

impl<N, const IN: usize, const OUT: usize, InP, OutP> Node<IN, OUT, InP, OutP> for NodeLink<N, IN, OUT, InP, OutP>
where InP: Payload, OutP: Payload, N: Node<IN, OUT, InP, OutP>,

Source§

impl<S, InP, const IN: usize> Node<IN, 0, InP, ()> for SinkNode<S, InP, IN>
where S: Sink<InP, IN>, InP: Payload + Copy,

Source§

impl<S, OutP, const OUT: usize> Node<0, OUT, (), OutP> for SourceNode<S, OutP, OUT>
where S: Source<OutP, OUT>, OutP: Payload + Copy,