Skip to main content

Crate knf

Crate knf 

Source
Expand description

Load, merge and interpolate homogeneous JSON or TOML configuration layers.

load_layers returns native Layers. Match its variant, then call merge, optionally interpolate, and format::emit on that same value type. No stage converts JSON to TOML or TOML to JSON.

Re-exports§

pub use format::ConfigFormat;
pub use format::Format;
pub use value::ConfigObject;
pub use value::ConfigValue;

Modules§

format
Format detection, parsing and emission.
fs
Discover ordered configuration inputs and filter path lists without loading them.
value
Native value adapters for the shared merge and interpolation algorithms.

Structs§

Cycle
A reference that resolves, directly or indirectly, to itself.
MergeOptions
Knobs on the merge itself. Passed by reference rather than encoded as cargo features: features are additive and unify across a dependency graph, so a strict feature would silently change behaviour for one consumer the moment a second consumer enabled it.
PathLeaf
A leaf value addressed by a parsed path.
ProcessEnv
Reads raw text for ${env:NAME}. The selected native adapter types it.
RefPath
A parsed path: dotted keys plus bracket array indices, a.b[2].c.

Enums§

InterpError
Why interpolation failed.
Layers
Native layers, all in one format and in the caller’s original order.
LoadError
Why a positional could not be turned into a layer.
MergeError
PathError
Why a path expression was rejected.
Problem
One thing wrong with one reference.
Seg
One step of a path into a document.
Syntax
A malformed reference.

Constants§

STDIN
The positional that means “read stdin”.

Traits§

Env
Where ${env:NAME} reads from.

Functions§

interpolate
Resolves every reference in doc.
json_or_string
Parses text as JSON, falling back to the string itself.
load_layers
Read homogeneous native layers after resolving one format for the entire list.
merge
Folds a list of layers into one document, seeded with an empty object.
merge_into
Merges over into base in place.
render_path
Renders a path for display: servers.primary.host, tags[0].
resolve_format
Resolve a single format without reading any document contents.
toml_or_string
Parse a standalone TOML value, falling back to the original text as a string. Surrounding TOML whitespace is ignored when parsing a literal. Invalid and out-of-range literals, including null, retain the original text as strings.