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 strHuman-readable name. Used in defmt logs and panic messages.
mode: ModeLifecycle 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
impl NodeCfg
Sourcepub const fn new(
name: &'static str,
mode: Mode,
spawn: Option<fn(Spawner) -> Result<(), SpawnError>>,
) -> Self
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.
Sourcepub const fn with_shell(self) -> Self
pub const fn with_shell(self) -> Self
Mark the node as a task: shell. Only shells can be stalled, crashed or hogged.
Sourcepub const fn with_executor(self, slot: &'static SpawnerSlot) -> Self
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!.
Sourcepub const fn with_resources(
self,
gates: &'static [&'static dyn ResourceGate],
) -> Self
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!.
Sourcepub const fn with_provides(
self,
slots: &'static [&'static dyn ResourceGate],
) -> Self
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!.
Sourcepub const fn with_claims(
self,
claims: &'static [(&'static dyn Divisible, u8)],
) -> Self
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!.
Sourcepub const fn with_ready_deps(self, deps: &'static [&'static TaskNode]) -> Self
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!.
Sourcepub const fn with_slot_timeout(self, timeout: Duration) -> Self
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!.
Sourcepub const fn with_ack_timeout(self, timeout: Duration) -> Self
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!.
Sourcepub const fn with_beat_timeout(self, timeout: Duration) -> Self
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!.
Sourcepub const fn with_beat_window(self, sweeps: u8) -> Self
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!.
Sourcepub const fn with_ready_on_write(self) -> Self
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.
Sourcepub const fn with_reads(self, reads: &'static [&'static [Coupling]]) -> Self
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!.
Sourcepub const fn with_writes(self, writes: &'static [&'static [Coupling]]) -> Self
pub const fn with_writes(self, writes: &'static [&'static [Coupling]]) -> Self
Declare the signals this node produces (the writes: graph clause).
See with_reads.
Sourcepub const fn with_bound_deps(self, deps: &'static [&'static TaskNode]) -> Self
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!.
Sourcepub const fn with_graph(self, graph: &'static GraphRef) -> Self
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!.