Skip to main content

NodeCfg

Struct NodeCfg 

Source
pub struct NodeCfg {
    pub name: &'static str,
    pub mode: Mode,
    pub spawn: Option<fn(Spawner) -> Result<(), SpawnError>>,
    /* private fields */
}
Expand description

The immutable half of a TaskNode: everything the graph declared about the node, none of what happens to it at runtime. No interior mutability, so the static carrying it lives in flash (.rodata); the RAM-resident node points at it. Built const with new plus the chainable with_* methods, exactly as supervisor_graph! emits it.

Fields§

§name: &'static str

Human-readable name. Used in defmt logs and panic messages.

§mode: Mode

Lifecycle policy. See Mode.

§spawn: Option<fn(Spawner) -> Result<(), SpawnError>>

App-provided spawn function (typically an inline closure at the node’s declaration). Called once at boot from Supervisor::start, again from respawn_terminate for Terminate nodes, and at runtime from start_node for OnDemand nodes. None for a parked node the application spawns itself (e.g. a Pause sensor holding a peripheral handle): the supervisor tracks its lifecycle but never spawns it.

Implementations§

Source§

impl NodeCfg

Source

pub const fn new( name: &'static str, mode: Mode, spawn: Option<fn(Spawner) -> Result<(), SpawnError>>, ) -> Self

The declared side of a single-instance node started at boot (Terminate/Pause) or on demand (Mode::OnDemand). Every node is single-instance; an elastic service is modelled as several OnDemand nodes of the same pooled task fn.

A node carries only its own identity and behaviour; the graph’s dependency edges live in the compile-time index table that supervisor_graph! emits and Supervisor::new consumes. spawn is None for a parked node the application spawns itself.

Source

pub const fn with_shell(self) -> Self

Mark the node as a task: shell. Only shells can be stalled, crashed or hogged.

Source

pub const fn with_executor(self, slot: &'static SpawnerSlot) -> Self

Route this node’s spawn through the given executor SpawnerSlot (the executor: NAME graph annotation). The supervisor awaits the slot before spawning the node, so a tier filled late — or from another core — is handled without a race, and the generated glue’s non-blocking get is already filled. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_resources( self, gates: &'static [&'static dyn ResourceGate], ) -> Self

Declare the ResourceSlots this node’s spawn takes from (the resources: graph clause). The supervisor awaits every gate being filled before spawning the node, so the generated glue’s non-blocking take() finds the value. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_provides( self, slots: &'static [&'static dyn ResourceGate], ) -> Self

Declare the slots this node’s task fills at runtime (the provides: graph clause); a stop ack clears them. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_claims( self, claims: &'static [(&'static dyn Divisible, u8)], ) -> Self

Declare the divisible budget slots this node claims (resources:). Released on stop. const and chainable; emitted by supervisor_graph!.

Source

pub const fn with_ready_deps(self, deps: &'static [&'static TaskNode]) -> Self

Declare the deps whose task-asserted readiness bring-up awaits before spawning this node (the ready-marked subset of deps:). const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_slot_timeout(self, timeout: Duration) -> Self

Override the pre-spawn slot/gate wait bound for this node (the slot_timeout: <millis> graph clause). The default (SLOT_READY_TIMEOUT, 100 ms) assumes slots are provided before start(); a node consuming a provider node’s outputs must cover the provider’s async build time (the failure mode stays a loud NodeFault, just later). const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_ack_timeout(self, timeout: Duration) -> Self

Override how long a stop waits for this node’s shutdown ack before faulting it with FaultKind::ShutdownTimeout (the ack_timeout: <millis> graph clause, default 2 s). Raise it for a node whose cleanup legitimately outlasts the default — a flash sync, a peripheral settle; the missed-ack failure mode stays a loud NodeFault, just later. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_beat_timeout(self, timeout: Duration) -> Self

Opt this node into liveness policing (the beat_timeout: <millis> graph clause): Supervisor::monitor reports it once it has been running without a beat for longer than timeout.

Only declare this on a node whose body actually beats — an un-beating node reads permanently stale. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_beat_window(self, sweeps: u8) -> Self

How many consecutive stale sweeps the monitor requires before it reports this node (the beat_window: <n> graph clause, default 1). Raise it for a node whose beat interval is legitimately jittery — the effective grace period becomes roughly beat_timeout + n sweep periods.

0 is treated as 1. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_ready_on_write(self) -> Self

Let an observed write assert readiness (the ready_on_write graph clause).

The sweep calls set_ready the first time one of this node’s observed writes advances, so “ready” means “actually producing” rather than “reached the line where it says so”. Requires beat_timeout:, which is what puts the node in the sweep at all.

Monotone by design: it never withdraws readiness. A node that goes quiet is reported through wait_health, and what to do about that stays the application’s decision.

Source

pub const fn with_reads(self, reads: &'static [&'static [Coupling]]) -> Self

Declare the signals this node consumes (the reads: graph clause). Purely descriptive: the supervisor never gates on it, and reads carry neither heartbeat nor readiness. What it buys is a graph that says what the node consumes — to Graph::readers_of, to the diagram tool. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_writes(self, writes: &'static [&'static [Coupling]]) -> Self

Declare the signals this node produces (the writes: graph clause). See with_reads.

Source

pub const fn with_bound_deps(self, deps: &'static [&'static TaskNode]) -> Self

Declare the bound-marked subset of deps: — providers whose readiness controls this node. const and chainable in a static initializer; emitted by supervisor_graph!.

Source

pub const fn with_graph(self, graph: &'static GraphRef) -> Self

Point the node at its own graph. const and chainable in a static initializer; emitted by supervisor_graph!.

Auto Trait Implementations§

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<T> CouplingPoint for T
where T: Sync + ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.