Skip to main content

EnvParam

Struct EnvParam 

Source
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

Source

pub const fn name(&self) -> &'static str

Source

pub const fn default_str(&self) -> &'static str

The compiled-in default string, exactly as it appears in C’s envData.c.

Source

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”.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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, then fallback.

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" = 5064
EPICS Environment "EPICS_CA_SERVER_PORT" out of range
Setting "EPICS_CA_SERVER_PORT" = 5064
Source

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.

Source

pub fn describe(&self) -> String

C envPrtConfigParam (envSubr.c:353-364) — one line of epicsPrtEnvParams.

Trait Implementations§

Source§

impl Clone for EnvParam

Source§

fn clone(&self) -> EnvParam

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for EnvParam

Source§

impl Debug for EnvParam

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for EnvParam

Source§

impl PartialEq for EnvParam

Source§

fn eq(&self, other: &EnvParam) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EnvParam

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more