Skip to main content

Crate kevy_config

Crate kevy_config 

Source
Expand description

kevy-config — TOML subset parser + Config schema for the kevy server.

Zero crates.io dependencies; #![forbid(unsafe_code)]. Built specifically for kevy’s config file shape; not a general-purpose TOML library.

Supported TOML subset:

  • [section] table headers (one level deep)
  • key = value with value ∈ {string, integer, boolean, size literal}
  • String literals: "double-quoted" and 'single-quoted'
  • Integers: signed decimal (123, -7); prefixed forms (0x/0o/0b) NOT supported
  • Booleans: true / false
  • Size literals (kevy-specific extension): "64mb" / "2gb" / "512kb" parsed via parse_size when the schema field expects bytes
  • # comment to end of line

INTENTIONALLY UNSUPPORTED (TOML spec features kevy doesn’t need):

  • dotted keys (a.b.c = ...)
  • multi-line strings ("""…""")
  • arrays / arrays of tables
  • inline tables ({ a = 1, b = 2 })
  • datetime literals

See Config for the schema, Config::load for the precedence chain.

Structs§

AdvancedSection
[advanced] section — reactor-loop tuning knobs that used to be hardcoded consts in kevy-rt. Defaults match the values shipped in workspace v1.3 / earlier so the existing benchmark numbers translate one-to-one. Tune only if you know what you’re doing (bench/REPORT.md documents the trade-offs).
CliOverrides
Optional CLI overrides applied via Config::merge_cli.
Config
Complete kevy config: defaults + per-section overrides loaded from the TOML file + env + CLI.
ExpirySection
[expiry] section. Controls the TTL background reaper.
LogSection
[log] section.
MemorySection
[memory] section.
NotificationFlags
Parsed view of NotificationSection::notify_keyspace_events. The runtime caches this struct per-shard (hot-reload via the existing LiveRuntimeConfig tick path) so the per-write-command check reduces to four bool reads on the hot path.
NotificationSection
[notification] section. notify_keyspace_events is a string of flag chars (Redis convention): K keyspace channel, E keyevent channel, g generic cmds, $ string cmds, l list, s set, h hash, z zset, A alias for g$lshz (every event class except the not-yet-implemented x/e/t/n). Default empty = OFF (Redis default — zero hot-path cost).
PersistenceSection
[persistence] section.
ServerSection
[server] section.
SlowlogSection
[slowlog] section — controls the per-shard slow-command ring buffer surfaced by SLOWLOG GET/LEN/RESET. Default is OFF (slower_than_micros = -1) so the hot path never pays the Instant::now() pair around dispatch (~30 ns/op, ≈9 % at 3 M ops/s). To enable Redis-style 10 ms tracking, set slower_than_micros = 10000 in [slowlog] or run CONFIG SET slowlog-log-slower-than 10000.

Enums§

AppendFsync
AOF fsync policy. Matches Redis appendfsync.
ConfigError
Reasons Config::load / from_toml_str can fail.
EvictionPolicy
Maxmemory eviction policy. 8 variants matching Redis. NoEviction (default) returns an error on writes once maxmemory is hit.
LogLevel
Log verbosity.
LogOutput
Where to write log output.

Functions§

parse_notification_flags
Parse a Redis-style notify_keyspace_events flag string into NotificationFlags. Unknown chars are ignored (forward-compat for x/e/t/n not yet implemented — see the section docs). The A alias enables every event-class flag except channels.
parse_size
Parse a size literal ("64mb", "2gb", "512", …) into a byte count.