Expand description
The hosted edge of configuration: every env var nano-ros honours is read here, and the core takes values.
Read through the C library’s getenv, so it needs
a C library and not std: target_os = "linux" is “a C library is linked”
on this tree. It exists on every Linux build, env or not, because the
C / C++ entries of a #![no_std] image inside a host process
(threadx-linux, freertos-posix) resolve their boot config
through it. The env FEATURE is the user-facing half: from_env, init*,
Context::new.
The hosted edge of configuration: the process environment.
Every env var nano-ros honours is read HERE and
nowhere else. The core (nros-node) takes values — ExecutorConfig:: resolve_with accepts an EnvRung of already-resolved fields — so it
needs no std, no env capability, and no stub on the five ports that have
no environment to read.
That is the difference between this and the ABI ports W10 made for the
clock, sleep, tasks and the log sink: those name capabilities every RTOS
HAS. A process environment is not one. Modelling it as an ABI entry would
have put return 0 in five ports and permanent surface in the header, for a
facility that exists on one platform family.
One reader, through the C library. The
environment is read with getenv, not std::env. A process environment is
a property of the PROCESS, not of the Rust standard library: threadx-linux
and freertos-posix are #![no_std] images that are still Linux processes
with a C library, and a measurement showed what happens when they stop
honouring $ROS_DOMAIN_ID (parallel cells shared a domain and heard each
other). There used to be two readers — this one on std::env and
on host_envgetenv — with the same variables and rules; they are one
now, and nros needs no std to be a hosted edge. The edge is “a C library
is linked”, which on this tree is target_os = "linux"; a cross target has
no getenv and this module does not exist there.
Strings are borrowed from the process environment, which outlives the boot,
so the resolved config’s &'static str fields point straight into it. No
cache is needed (the old std::env reader kept a OnceLock only to turn an
owned String into a &'static str, and its staleness was a bug).
Nothing in nano-ros calls setenv after boot.
What lives here:
ExecutorConfigEnvExt::from_env— the constructor that used to be an inherent method onExecutorConfig. Bring the trait into scope (the prelude has it) and the call site spelling is unchanged.envfeature.resolve_hosted/try_resolve_hosted— the boot-config precedence ladder with the environment rung on top. The C / C++ entries call these on every Linux build,envor not.rmw_selector— the one$NROS_RMWreader.var/read_file— the two C-library reads the hostedinit*entries need ($RMW_IMPLEMENTATION,--params-file).write_file,rename,set_var,exe_name,thread_key,exit— the rest of the hosted PROCESS edge, for the C / C++ surfaces.nros-candnros-cppwrite their census, metadata and profile files through these instead ofstd::fs/std::process, so the image root never links libstd: a census is a property of a process with a C library, not of the Rust standard library. One spelling of each C-library call, here, rather than one per crate.
Structs§
- Statement
Overrides - Where the environment overrides a value the image’s
system.tomlSTATED, each as(env, stated). Only a value both sides state and that differs is reported: an unstated one has nothing to override, and an equal one changes nothing.
Traits§
- Executor
Config EnvExt ExecutorConfig::from_env(), as an extension trait.
Functions§
- env_
overrides_ statement - The pure decision behind
warn_env_overrides_statement. - exe_
name - The file name of this process’s executable (
/proc/self/exe’s last component) — whatstd::env::current_exe()+file_name()gave.Nonewhen the link cannot be read. - exit
- End the process with
code, runningatexithandlers and flushing stdio —std::process::exit. - read_
file - A whole file, through the C library —
std::fs::read_to_stringfor a crate with nostd.--params-filereads through it, and so do the C / C++ surfaces’ own params-file entries. - rename
- Rename
fromtoto, replacingto—std::fs::rename. Same filesystem only, which is how its callers use it (write-then-rename beside the target). - resolve_
hosted - The boot-config precedence ladder with the environment on top:
env (var set) > baked > compiled default. - rmw_
selector - The answer to “which RMW backend did the user select” — one reader, one semantic, for every consumer.
- set_var⚠
- Set
$nametovaluefor this process —std::env::set_var. - thread_
key - A key unique to the calling thread among live threads — the address a
thread_local!would give, withoutstd.pthread_ton Linux is the thread’s descriptor address. - try_
resolve_ hosted - Fallible
resolve_hosted— returnsBootConfigErrorinstead of panicking, so the C / C++ FFI shims can surface a return code. - var
$NAMEas UTF-8, orNonewhen unset or not UTF-8 (std::env::var’s twoErrcases, which the old std reader also treated as unset).- warn_
env_ overrides_ statement - On a host the environment WINS over what the image’s
system.tomlstates (a user ruling, for testing convenience), and says so at boot, one warning per field, throughnros_log. - write_
file - Write
bytestopath, creating or truncating it —std::fs::writefor a crate with nostd. The error is a short reason, as forread_file.