Skip to main content

RuntimeCtx

Struct RuntimeCtx 

Source
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 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).

§env: &'a [(&'a str, &'a str)]

Environment-style key/value pairs (mostly POSIX). Empty on embedded boards.

§runtime: &'a mut dyn NodeDispatchRuntime

Node 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>

Source

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.

Source

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).

Source

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).

Source

pub fn remap(&self, from: &str) -> Option<&'a str>

Lookup a remap by the original (from) name; returns the rewritten name when remapped, else None.

Source

pub fn env_var(&self, name: &str) -> Option<&'a str>

Lookup an env entry by name.

Trait Implementations§

Source§

impl Debug for RuntimeCtx<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RuntimeCtx<'a>

§

impl<'a> !RefUnwindSafe for RuntimeCtx<'a>

§

impl<'a> !Send for RuntimeCtx<'a>

§

impl<'a> !Sync for RuntimeCtx<'a>

§

impl<'a> Unpin for RuntimeCtx<'a>

§

impl<'a> UnsafeUnpin for RuntimeCtx<'a>

§

impl<'a> !UnwindSafe for RuntimeCtx<'a>

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> 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 = 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.