pub struct RuntimeCtx<'a> {
pub params: &'a [(&'a str, &'a str)],
pub remaps: &'a [(&'a str, &'a str)],
pub env: &'a [(&'a str, &'a str)],
pub node_identity: Option<(&'static str, &'static str)>,
pub qos_overrides: &'static [(&'static str, u8, u8, u32)],
pub runtime: &'a mut dyn NodeDispatchRuntime,
}Expand description
Runtime context handed to BoardEntry::run(setup).
All three overlay slices may be empty. A board’s launch overlay
typically populates params + remaps; env is rarely set on
embedded.
Fields§
§params: &'a [(&'a str, &'a str)]<param name=… value=…/> from launch XML, or
-p name:=value CLI overrides.
remaps: &'a [(&'a str, &'a str)]Topic / service / action remaps: (from, to), set per component by
nros::main! from the model’s launch <remap> rules (phase-306 W3,
issue 0255). nros::node!’s register forwards them into
install_node_typed_with_launch, where entity creation expands
~/relative names and substitutes matching rules (exact-FQN match,
first rule wins).
env: &'a [(&'a str, &'a str)]Environment-style key/value pairs (mostly POSIX). Empty on embedded boards.
node_identity: Option<(&'static str, &'static str)>Phase 268 W1 — launch-injected node identity (name, namespace) for
the NEXT register() call, set by nros::main! per component before
each <pkg>::register(runtime)? call. None → the node’s own
create_node(NodeOptions::new("…")) default stands (backward-compatible).
Reset to None after every register in the self-bringup arm so a prior
component’s identity never leaks into the next (RFC-0046).
qos_overrides: &'static [(&'static str, u8, u8, u32)]Issue #52 — per-node QoS overrides for the NEXT register() call, baked
by nros::main! from the model’s
qos_overrides.<topic>.<role>.<policy> params. Same reset discipline as
params/remaps: &[] when the node has none, so a prior component’s
table never leaks into the next.
Primitive (topic, role, policy, value) codes — the SAME wire form the
C and C++ ABIs use — because nros-platform sits below nros-rmw in the
layer graph and a typed QoSOverride field here would invert it. The
register seam installs them via Executor::set_node_qos_overrides, which
decodes at entity-create time.
runtime: &'a mut dyn NodeDispatchRuntimeNode runtime sink. BoardEntry::run populates this with
the live ExecutorNodeRuntime-backed impl before invoking
the user setup closure. The codegen-emitted
run_plan(runtime) body calls <pkg>::register(runtime) once per Node
pkg, which installs through runtime.executor_handle() +
nros::install_node_typed (Phase 258, Track 2).
Defaults to a NullNodeRuntime when the context is
built via RuntimeCtx::with_runtime. That sink errors
every call so test fixtures that forget to wire a real runtime
fail loud.
Implementations§
Source§impl<'a> RuntimeCtx<'a>
impl<'a> RuntimeCtx<'a>
Sourcepub fn with_runtime(runtime: &'a mut dyn NodeDispatchRuntime) -> Self
pub fn with_runtime(runtime: &'a mut dyn NodeDispatchRuntime) -> Self
Build a RuntimeCtx with no params / remaps / env and the
given runtime sink. The common shape BoardEntry::run
constructs after opening its executor.
For test fixtures that don’t need a populated runtime, pass a
&mut NullNodeRuntime — every call against the sink
returns Err(()), surfacing the missing wiring.
Sourcepub fn new(
runtime: &'a mut dyn NodeDispatchRuntime,
params: &'a [(&'a str, &'a str)],
remaps: &'a [(&'a str, &'a str)],
env: &'a [(&'a str, &'a str)],
) -> Self
pub fn new( runtime: &'a mut dyn NodeDispatchRuntime, params: &'a [(&'a str, &'a str)], remaps: &'a [(&'a str, &'a str)], env: &'a [(&'a str, &'a str)], ) -> Self
Build a RuntimeCtx with explicit overlay slices + runtime
sink (Phase 212.N.7 step-3.2).
Sourcepub fn apply_lifecycle(&mut self, autostart: u8) -> Result<(), &'static str>
pub fn apply_lifecycle(&mut self, autostart: u8) -> Result<(), &'static str>
Phase 264 W2 — register lifecycle services + drive autostart on the runtime
sink (forwards to NodeDispatchRuntime::apply_lifecycle). nros::main!
emits this after the per-node register calls when system.toml declares
[lifecycle]. No-op unless nros is built with lifecycle-services.
Sourcepub fn apply_param_services(
&mut self,
params: &[(&str, &str)],
) -> Result<(), &'static str>
pub fn apply_param_services( &mut self, params: &[(&str, &str)], ) -> Result<(), &'static str>
Phase 264 W4b — register the ROS 2 parameter services + seed the volatile
param store from the launch-baked <param> initials (forwards to
NodeDispatchRuntime::apply_param_services). nros::main! emits this after
the per-node register calls when system.toml declares [param_services].
No-op unless nros is built with param-services.
Sourcepub fn param(&self, name: &str) -> Option<&'a str>
pub fn param(&self, name: &str) -> Option<&'a str>
Lookup a param by name; first match wins. Linear scan because the slice is typically small (≤ a dozen entries).