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 strMiddleware-specific connection string.
mode: SessionModeSession mode (client or peer).
domain_id: u32ROS 2 domain ID.
node_name: &'a strNode name.
namespace: &'a strNode 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>
impl<'a> ExecutorConfig<'a>
Sourcepub const fn new(locator: &'a str) -> ExecutorConfig<'a>
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.
Sourcepub const fn default_const() -> ExecutorConfig<'a>
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>
impl<'a> ExecutorConfig<'a>
Sourcepub const fn domain_id(self, id: u32) -> ExecutorConfig<'a>
pub const fn domain_id(self, id: u32) -> ExecutorConfig<'a>
Set the ROS 2 domain ID.
Sourcepub const fn node_name(self, name: &'a str) -> ExecutorConfig<'a>
pub const fn node_name(self, name: &'a str) -> ExecutorConfig<'a>
Set the node name.
Sourcepub const fn namespace(self, ns: &'a str) -> ExecutorConfig<'a>
pub const fn namespace(self, ns: &'a str) -> ExecutorConfig<'a>
Set the node namespace.
Sourcepub const fn mode(self, mode: SessionMode) -> ExecutorConfig<'a>
pub const fn mode(self, mode: SessionMode) -> ExecutorConfig<'a>
Set the session mode.
Sourcepub const fn epoch_us(self, epoch: fn() -> u64) -> ExecutorConfig<'a>
pub const fn epoch_us(self, epoch: fn() -> u64) -> ExecutorConfig<'a>
RFC-0052 W3b.2 — set the wall-clock (epoch µs) source.
Sourcepub const fn clock_us(self, clock: fn() -> u64) -> ExecutorConfig<'a>
pub const fn clock_us(self, clock: fn() -> u64) -> ExecutorConfig<'a>
Set the monotonic microsecond clock for the executor’s timers.
Sourcepub const fn rmw(self, rmw: &'a str) -> ExecutorConfig<'a>
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>
impl<'a> ExecutorConfig<'a>
Sourcepub fn resolve(baked: BootConfig<'a>) -> ExecutorConfig<'a>
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.
Sourcepub fn resolve_with(
baked: BootConfig<'a>,
env: Option<EnvRung<'a>>,
) -> ExecutorConfig<'a>
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.
Sourcepub fn try_resolve(
baked: BootConfig<'a>,
) -> Result<ExecutorConfig<'a>, BootConfigError>
pub fn try_resolve( baked: BootConfig<'a>, ) -> Result<ExecutorConfig<'a>, BootConfigError>
RFC-0045 / issue #206 — fallible resolve.
Sourcepub fn try_resolve_with(
baked: BootConfig<'a>,
env: Option<EnvRung<'a>>,
) -> Result<ExecutorConfig<'a>, BootConfigError>
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.