pub struct EnvParam { /* private fields */ }Expand description
One row of C’s ENV_PARAM table (envDefs.h:41-45): a parameter name and
the default compiled in from configure/CONFIG_ENV.
Values of this type exist only in the generated super::env_table.
Implementations§
Source§impl EnvParam
impl EnvParam
pub const fn name(&self) -> &'static str
Sourcepub const fn default_str(&self) -> &'static str
pub const fn default_str(&self) -> &'static str
The compiled-in default string, exactly as it appears in C’s
envData.c.
Sourcepub fn get(&self) -> Option<String>
pub fn get(&self) -> Option<String>
C envGetConfigParamPtr (envSubr.c:81-100): the environment string,
falling back to the compiled default — with an empty result mapped to
None.
The None/Some answer is a load-bearing presence test, not just an
absence check: caservertask.c:491-508 uses it to pick which of two
parameters to resolve, so FOO= must read as “not configured”.
Sourcepub fn long(&self) -> Option<i64>
pub fn long(&self) -> Option<i64>
C envGetLongConfigParam (envSubr.c:303-320) — sscanf("%ld") over the
resolved value, out of the first 127 bytes (all C’s char text[128]
keeps).
None is C’s non-zero status. A set-but-unparseable value also prints
C’s stderr line first; an unresolvable one (empty value and empty
default) prints nothing, because envGetConfigParam returned NULL before
sscanf ever ran.
Sourcepub fn long_or_default(&self) -> i64
pub fn long_or_default(&self) -> i64
The C caller idiom for a long-valued parameter:
long i = 50; /* == the table default */
envGetLongConfigParam(&IOCSH_HISTSIZE, &i);i.e. a rejected value leaves the compiled default standing. The 50 in
C’s source is a hand-copy of the table; here it comes from the table.
Sourcepub fn double(&self) -> Result<f64, EnvDoubleError>
pub fn double(&self) -> Result<f64, EnvDoubleError>
C envGetDoubleConfigParam (envSubr.c:191-211) — epicsScanDouble over
the resolved value.
An unset parameter resolves to its compiled default and parses, so
Ok(30.0) for EPICS_CA_CONN_TMO on a clean shell. Err is C’s non-zero
status: the value (or the default) is empty, or it did not scan — and in
the latter case C’s stderr line has already been printed. C’s callers then
print their own named diagnostic on top of it.
Sourcepub fn bool(&self) -> Option<bool>
pub fn bool(&self) -> Option<bool>
C envGetBoolConfigParam (envSubr.c:324-333):
*pBool = epicsStrCaseCmp(text, "yes") == 0, i.e. true iff the
resolved value is the word yes, any case. "1", "true", "on",
"yes " are all false.
None is C’s -1 status — nothing to compare, so C leaves the caller’s
variable untouched. The caller’s unwrap_or(..) is then C’s own
initializer, not a second copy of the table default.
Sourcepub fn inet_port(&self, fallback: u16) -> u16
pub fn inet_port(&self, fallback: u16) -> u16
C envGetInetPortConfigParam (envSubr.c:397-424).
fallback is the compiled port the C caller passes as defaultPort
— for the EPICS_CAS_* overrides that is a different parameter’s
default (caservertask.c:491-508 passes CA_SERVER_PORT), which is why
it is an argument rather than self.default. Derive it with
EnvParam::default_port so it still comes from the table.
- Not resolvable, or no integer found: the “integer fetch failed”
diagnostics, then
fallback. <= IPPORT_USERRESERVED(5000) or> USHRT_MAX: the “out of range” diagnostics, thenfallback.
The diagnostics are byte-identical to compiled C, once per resolution — there is no dedup in C:
Unable to find an integer in EPICS_CA_SERVER_PORT=abc
EPICS Environment "EPICS_CA_SERVER_PORT" integer fetch failed
setting "EPICS_CA_SERVER_PORT" = 5064EPICS Environment "EPICS_CA_SERVER_PORT" out of range
Setting "EPICS_CA_SERVER_PORT" = 5064Sourcepub const fn default_port(&self) -> u16
pub const fn default_port(&self) -> u16
The compiled default read as a port, at compile time.
This is how a pub const CA_SERVER_PORT: u16 is derived from the table
instead of hand-written next to it: a default that is not a valid port
fails const-evaluation, so the constant cannot drift from CONFIG_ENV.