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 epoch_us: Option<fn() -> u64>,
}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.
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.
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.
Source§impl ExecutorConfig<'static>
impl ExecutorConfig<'static>
Sourcepub fn from_env() -> ExecutorConfig<'static>
pub fn from_env() -> ExecutorConfig<'static>
Create a configuration from environment variables.
Reads:
NROS_LOCATOR— Middleware locator (default:"tcp/127.0.0.1:7447"). Legacy nameZENOH_LOCATORis accepted with a deprecation warning.ROS_DOMAIN_ID— ROS 2 domain ID (default:0).NROS_SESSION_MODE— Session mode:"client"or"peer"(default:"client"). Legacy nameZENOH_MODEis accepted with a deprecation warning.
Env-var values are cached in a process-global OnceLock on the
first call and reused for the process lifetime — repeated calls
do NOT re-read the environment and do NOT accrete memory. The
returned &'static str fields point into the cache.
Source§impl<'a> ExecutorConfig<'a>
impl<'a> ExecutorConfig<'a>
Sourcepub fn resolve(baked: BootConfig<'a>, hosted_env: bool) -> ExecutorConfig<'a>
pub fn resolve(baked: BootConfig<'a>, hosted_env: bool) -> ExecutorConfig<'a>
Resolve boot config under precedence model A (RFC-0045).
Per-field precedence (evaluated independently):
env (hosted_env && var set) > baked > compiled default.
hosted_env=true enables the env-override layer (std only).
Embedded callers always pass false; the env layer compiles out
on no_std regardless of the flag value.
When hosted_env=true the env layer is queried fresh from the
process environment at call time; string storage for env-derived
fields comes from the process-global [EnvCache] (same backing
store as ExecutorConfig::from_env). Passing
BootConfig::default() with hosted_env=true is therefore
equivalent to calling from_env() directly.
Note on env coupling: The env-presence checks below
(NROS_LOCATOR/ZENOH_LOCATOR/ROS_DOMAIN_ID) must stay in sync
with the env vars that [env_cache()] reads. If a new locator or
domain env var is added there, add the corresponding presence check
here too.
Sourcepub fn try_resolve(
baked: BootConfig<'a>,
hosted_env: bool,
) -> Result<ExecutorConfig<'a>, BootConfigError>
pub fn try_resolve( baked: BootConfig<'a>, hosted_env: bool, ) -> Result<ExecutorConfig<'a>, BootConfigError>
RFC-0045 / issue #206 — fallible resolve. Same precedence model A as
resolve; returns BootConfigError instead of
panicking on malformed / out-of-range identity input, so the C / C++
FFI shims can surface a return code. Validation is uniform across
languages:
ROS_DOMAIN_IDset but non-numeric →DomainIdParse(the pre-#206 C++ header silently collapsed this to domain 0; this resolver silently ignored it — both were wrong).- any resolved domain id >
DOMAIN_ID_MAX→DomainIdRange(including a BAKED value — the DDS backend would only fail later). NROS_NODE_NAMEjoins the hosted env rung (model A parity).