Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub server: ServerSection,
    pub persistence: PersistenceSection,
    pub memory: MemorySection,
    pub expiry: ExpirySection,
    pub log: LogSection,
    pub notification: NotificationSection,
    pub advanced: AdvancedSection,
    pub slowlog: SlowlogSection,
    pub cluster: ClusterSection,
    pub source_path: Option<PathBuf>,
}
Expand description

Complete kevy config: defaults + per-section overrides loaded from the TOML file + env + CLI.

Fields§

§server: ServerSection

[server] settings.

§persistence: PersistenceSection

[persistence] settings.

§memory: MemorySection

[memory] settings.

§expiry: ExpirySection

[expiry] settings.

§log: LogSection

[log] settings.

§notification: NotificationSection

[notification] settings (keyspace events).

§advanced: AdvancedSection

[advanced] settings (reactor tuning knobs).

§slowlog: SlowlogSection

[slowlog] settings (slow-command ring buffer).

§cluster: ClusterSection

[cluster] settings (single-node cluster mode).

§source_path: Option<PathBuf>

Path the config was loaded from (for CONFIG REWRITE). None = loaded from defaults only / from in-memory string.

Implementations§

Source§

impl Config

Source

pub fn to_toml_string_preserving( &self, original_source: &str, ) -> Result<String, ConfigError>

Render the live config back into TOML preserving every comment, blank line, and key order from original_source. Schema fields missing from the source are appended at file end, grouped by section. Returns a ConfigError::Parse if original_source can’t be re-parsed line-by-line (caller is expected to fall back to Self::to_toml_string).

Source§

impl Config

Source

pub fn load(path: Option<&Path>) -> Result<Self, ConfigError>

Load config from the given explicit path, or auto-detect.

Auto-detect order (first hit wins):

  1. $KEVY_DIR/kevy.toml (if KEVY_DIR env is set)
  2. ./kevy.toml
  3. /etc/kevy/kevy.toml

If path is Some, that file is required to exist; otherwise returns Ok(Config::default()) if no auto-detect path matched.

Source

pub fn from_toml_str( text: &str, source_path: Option<&Path>, ) -> Result<Self, ConfigError>

Parse a TOML string (no file I/O). source_path is used for error reporting and CONFIG REWRITE write-back; pass None for in-memory.

Source

pub fn merge_env<I, K, V>(&mut self, env: I) -> Result<(), ConfigError>
where I: IntoIterator<Item = (K, V)>, K: AsRef<str>, V: AsRef<str>,

Overlay environment variable values onto self. Iterates a caller-provided (name, value) list so tests can pump a fixture without touching the real env. The recognised variables match the pre-kevy-config set:

  • KEVY_BIND / KEVY_PORT / KEVY_THREADS / KEVY_DIR / KEVY_AOF

Unknown variables are silently ignored (env may contain many unrelated keys).

Source

pub fn merge_cli(&mut self, cli: CliOverrides) -> Result<(), ConfigError>

Overlay parsed-from-CLI overrides onto self. Pass a struct of optional values (any Some(_) field overrides the corresponding schema field). Tests pass a literal; the kevy binary builds one from std::env::args.

Source

pub fn to_toml_string(&self) -> String

Render the current config as a standard-template TOML file — every field, in stable section/key order, with no comments. Used by CONFIG REWRITE; the loss of any inline comments the user had in their hand-edited file is the documented v1.0 trade-off (v1.x will preserve them).

Round-trips: feeding the output back through Self::from_toml_str reconstructs an equivalent Config (modulo source_path).

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl Eq for Config

Source§

impl PartialEq for Config

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Config

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.