Expand description
issue 0687 — the hosted edge of configuration: every env var nano-ros honours is read here, and the core takes values.
phase-359 W10 stage B — 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 — issue 1763) 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.
issue 0687 / phase-359 W10. 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 (phase-359 W10 stage B). 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 issue 1763 measured 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 issue 0607).
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— RFC-0045 precedence model A with the environment rung on top. The C / C++ entries call these on every Linux build,envor not.rmw_selector— the one$NROS_RMWreader (issue 0687’s first half).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 (phase-359 W10 stage C).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.
Traits§
- Executor
Config EnvExt ExecutorConfig::from_env(), as an extension trait.
Functions§
- 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 - RFC-0045 precedence model A 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).- write_
file - Write
bytestopath, creating or truncating it —std::fs::writefor a crate with nostd. The error is a short reason, as forread_file.