#[non_exhaustive]pub struct ConfigOptions {
pub read_only: bool,
pub cache_enabled: bool,
pub cache_capacity: usize,
}Expand description
Opt-out behavior knobs for Config.
ConfigOptions carries the small set of toggles that should not be
enabled by default: making a Config read-only, sizing the cache,
and so on. The struct is #[non_exhaustive] so v0.9.x can add new
knobs without breaking SemVer. Users construct it via
ConfigOptions::new or ConfigOptions::default and apply
individual toggles through the consuming builder methods.
The field set lays the groundwork for the lock-free caching work
landing in v0.9.5. In v0.9.4 the only knob that has runtime effect
is ConfigOptions::read_only; the cache-related knobs are
accepted today so that the public API surface does not change
again when v0.9.5 switches the cache on.
§Examples
use config_lib::{Config, ConfigOptions};
// Default options — caching on, writes allowed.
let _cfg = Config::with_options(ConfigOptions::default());
// Read-only configuration for a hot path that must never be mutated.
let opts = ConfigOptions::new().read_only(true);
let _cfg = Config::with_options(opts);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.read_only: boolReject every set / remove / merge call with
Error::general instead of mutating. Useful for once-loaded
configurations that must never change at runtime.
cache_enabled: boolWhether the internal caching layer is active. Reserved — the
caching layer ships in v0.9.5; in v0.9.4 this field is accepted
for forward compatibility but does not yet change runtime
behavior (every get already hits an in-memory Value).
cache_capacity: usizeMaximum number of resolved-key entries the cache will hold before evicting. Reserved for v0.9.5.
Implementations§
Source§impl ConfigOptions
impl ConfigOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a ConfigOptions with default values
(ConfigOptions::default).
Sourcepub fn read_only(self, read_only: bool) -> Self
pub fn read_only(self, read_only: bool) -> Self
Set the read-only flag. See ConfigOptions::read_only.
Sourcepub fn cache_enabled(self, cache_enabled: bool) -> Self
pub fn cache_enabled(self, cache_enabled: bool) -> Self
Toggle the caching layer. Reserved for v0.9.5 — currently a no-op at runtime; the setter exists so call-sites compile against the same shape they will use after the cache lands.
Sourcepub fn cache_capacity(self, cache_capacity: usize) -> Self
pub fn cache_capacity(self, cache_capacity: usize) -> Self
Set the cache capacity. Reserved for v0.9.5 — see
ConfigOptions::cache_enabled.
Trait Implementations§
Source§impl Clone for ConfigOptions
impl Clone for ConfigOptions
Source§fn clone(&self) -> ConfigOptions
fn clone(&self) -> ConfigOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more