Skip to content

NullConfigSerializer

No-op IConfigSerializer: load and save do nothing, and the string-based methods all throw. Useful as a ConfigSpec.fileSerializer override for a spec that should never persist to disk (e.g. an in-memory-only or test config).

Functions

configPath

open override fun configPath(config: ConfigSpec, configFolder: Path): Path

File the given config is read from and written to, resolved under configFolder.

load

open override fun load(config: ConfigSpec, configFolder: Path)

Reads config's file if present via loadString, then always saves it back out - this both formats a freshly-created file with defaults and rewrites an existing one with any newly-added fields. If the existing file fails to parse, it's logged and renamed to <file>.corrupted rather than deleted, and loading falls through to writing fresh defaults so startup isn't blocked.

loadString

open override fun loadString(config: ConfigSpec, string: String)

Parses string and populates config's fields from it. Implemented per-format.

save

open override fun save(config: ConfigSpec, configFolder: Path)

Writes config's current field values to configPath, creating parent directories as needed.

saveString

open override fun saveString(config: ConfigSpec): String

Renders config's current field values as a file-format string. Implemented per-format.