Skip to main content

ExecutorConfig

Struct ExecutorConfig 

Source
pub struct ExecutorConfig<'a> {
    pub locator: &'a str,
    pub mode: SessionMode,
    pub domain_id: u32,
    pub node_name: &'a str,
    pub namespace: &'a str,
    pub clock_us: Option<fn() -> u64>,
    pub epoch_us: Option<fn() -> u64>,
    pub rmw: Option<&'a str>,
}
Expand description

Configuration for opening an embedded executor session.

Provides a backend-agnostic builder for configuring the middleware connection. The active Cargo feature (rmw-zenoh, rmw-xrce, or rmw-cffi) determines which backend is used.

§Example

use nros::prelude::*;

let config = ExecutorConfig::new("tcp/127.0.0.1:7447")
    .node_name("talker")
    .domain_id(0);
let mut executor: Executor = Executor::open(&config)?;

Fields§

§locator: &'a str

Middleware-specific connection string.

§mode: SessionMode

Session mode (client or peer).

§domain_id: u32

ROS 2 domain ID.

§node_name: &'a str

Node name.

§namespace: &'a str

Node namespace.

§clock_us: Option<fn() -> u64>

Monotonic microsecond clock for the executor’s timer accounting.

phase-359 W10 — was no_std-only, because the std build read an Instant instead and had nothing to override. There is one clock now, so the override applies to every flavour: a hosted caller that wants simulated or externally-driven time can supply it here rather than being told that is an embedded-only capability.

§epoch_us: Option<fn() -> u64>

RFC-0052 / phase-296 W3b.2 — wall-clock µs since the UNIX epoch, for now - header.stamp age monitors. Distinct from the monotonic clock_us: header.stamp is ROS (wall) time. None = no epoch source on this target — a baked max_age_ms contract with no epoch source is a BAKE-time error (fail-loud, never a silently-dead monitor). On std targets the executor falls back to SystemTime::now() when unset.

§rmw: Option<&'a str>

The RMW backend the caller selected, by the cffi registry’s canonical name (zenoh, cyclonedds, xrce, uorb). None = no selection: Executor::open then takes the unique registered backend, and reports Ambiguous when there is more than one.

issue 0687 — this used to be read from $NROS_RMW INSIDE Executor::open, which is why the core crate needed a process environment at all. A backend selection is a decision the hosted edge makes and hands down, exactly like the locator beside it; nros::ExecutorConfigEnvExt::from_env and nros::env::resolve_hosted fill this from $NROS_RMW, and an embedded image bakes it or leaves it None.

Implementations§

Source§

impl<'a> ExecutorConfig<'a>

Source

pub const fn new(locator: &'a str) -> ExecutorConfig<'a>

Create a new configuration with the given locator.

Defaults: Client mode, domain 0, node name "node", empty namespace.

Source

pub const fn default_const() -> ExecutorConfig<'a>

Phase 104.C.3.3.b — Default-style constructor with an empty locator. Most users want ExecutorConfig::from_env() to pick up ZENOH_LOCATOR / ROS_DOMAIN_ID; this is the rclcpp-NodeOptions{} shape for callers that set every field explicitly via the chaining setters.

Source§

impl<'a> ExecutorConfig<'a>

Source

pub const fn domain_id(self, id: u32) -> ExecutorConfig<'a>

Set the ROS 2 domain ID.

Source

pub const fn node_name(self, name: &'a str) -> ExecutorConfig<'a>

Set the node name.

Source

pub const fn namespace(self, ns: &'a str) -> ExecutorConfig<'a>

Set the node namespace.

Source

pub const fn mode(self, mode: SessionMode) -> ExecutorConfig<'a>

Set the session mode.

Source

pub const fn epoch_us(self, epoch: fn() -> u64) -> ExecutorConfig<'a>

RFC-0052 W3b.2 — set the wall-clock (epoch µs) source.

Source

pub const fn clock_us(self, clock: fn() -> u64) -> ExecutorConfig<'a>

Set the monotonic microsecond clock for the executor’s timers.

Source

pub const fn rmw(self, rmw: &'a str) -> ExecutorConfig<'a>

issue 0687 — select the RMW backend by its canonical registry name.

Source§

impl<'a> ExecutorConfig<'a>

Source

pub fn resolve(baked: BootConfig<'a>) -> ExecutorConfig<'a>

Resolve boot config under precedence model A (RFC-0045), with no environment rung: baked > compiled default.

Panics on invalid identity input — fail-loud (repo rule): a bad domain id at boot is a configuration error, never a silent domain-0 node. FFI shims that need an error code call try_resolve.

Source

pub fn resolve_with( baked: BootConfig<'a>, env: Option<EnvRung<'a>>, ) -> ExecutorConfig<'a>

resolve with an environment rung on top.

Hosted callers reach this through nros::env::resolve_hosted, which fills the rung from the process environment.

Source

pub fn try_resolve( baked: BootConfig<'a>, ) -> Result<ExecutorConfig<'a>, BootConfigError>

RFC-0045 / issue #206 — fallible resolve.

Source

pub fn try_resolve_with( baked: BootConfig<'a>, env: Option<EnvRung<'a>>, ) -> Result<ExecutorConfig<'a>, BootConfigError>

RFC-0045 / issue #206 — fallible resolve with an environment rung. Returns BootConfigError instead of panicking on out-of-range identity input, so the C / C++ FFI shims can surface a return code. Validation is uniform across languages: any resolved domain id > DOMAIN_ID_MAX is BootConfigError::DomainIdRange, INCLUDING a baked one (the DDS backend would only fail later).

Fields resolve independently: an env locator and a baked node_name can both apply in the same call.

Trait Implementations§

Source§

impl Default for ExecutorConfig<'_>

Source§

fn default() -> ExecutorConfig<'_>

Returns the “default value” for a type. Read more
Source§

impl ExecutorConfigEnvExt for ExecutorConfig<'static>

Source§

fn from_env() -> ExecutorConfig<'static>

Create a configuration from environment variables. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ExecutorConfig<'a>

§

impl<'a> RefUnwindSafe for ExecutorConfig<'a>

§

impl<'a> Send for ExecutorConfig<'a>

§

impl<'a> Sync for ExecutorConfig<'a>

§

impl<'a> Unpin for ExecutorConfig<'a>

§

impl<'a> UnsafeUnpin for ExecutorConfig<'a>

§

impl<'a> UnwindSafe for ExecutorConfig<'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.