Skip to main content

ConfigOptions

Struct ConfigOptions 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§read_only: bool

Reject every set / remove / merge call with Error::general instead of mutating. Useful for once-loaded configurations that must never change at runtime.

§cache_enabled: bool

Whether 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: usize

Maximum number of resolved-key entries the cache will hold before evicting. Reserved for v0.9.5.

Implementations§

Source§

impl ConfigOptions

Source

pub fn new() -> Self

Construct a ConfigOptions with default values (ConfigOptions::default).

Source

pub fn read_only(self, read_only: bool) -> Self

Set the read-only flag. See ConfigOptions::read_only.

Source

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.

Source

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

Source§

fn clone(&self) -> ConfigOptions

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 Debug for ConfigOptions

Source§

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

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

impl Default for ConfigOptions

Source§

fn default() -> Self

The canonical options for the Hive DB use case: caching enabled, writes allowed, capacity tuned for typical server config size.

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