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
impl Config
Sourcepub fn to_toml_string_preserving(
&self,
original_source: &str,
) -> Result<String, ConfigError>
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
impl Config
Sourcepub fn load(path: Option<&Path>) -> Result<Self, ConfigError>
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):
$KEVY_DIR/kevy.toml(ifKEVY_DIRenv is set)./kevy.toml/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.
Sourcepub fn from_toml_str(
text: &str,
source_path: Option<&Path>,
) -> Result<Self, ConfigError>
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.
Sourcepub fn merge_env<I, K, V>(&mut self, env: I) -> Result<(), ConfigError>
pub fn merge_env<I, K, V>(&mut self, env: I) -> Result<(), ConfigError>
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).
Sourcepub fn merge_cli(&mut self, cli: CliOverrides) -> Result<(), ConfigError>
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.
Sourcepub fn to_toml_string(&self) -> String
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).