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.
glob
Validated glob predicates and quoted, dotted key-path selectors.
value
Native value adapters for the shared merge and interpolation algorithms.

Structs§

Cycle
A reference that resolves to itself, reported as the full chain.
MergeOptions
Merge options.
PathLeaf
A leaf value addressed by a parsed path: server.port=8080.
ProcessEnv
Reads raw text for ${env:NAME}. The selected native adapter types it.
RefPath
A non-empty parsed path: dotted keys plus bracket indices, a.b[2].c.

Enums§

InterpError
Why interpolation failed: every problem found, or a single cycle.
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. Carries only the path text.
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. ProcessEnv reads the real environment.

Functions§

interpolate
Resolves every reference in doc. Call once, on the merged document.
json_or_string
Parses text as JSON, falling back to the string itself: 8080 is a number, foo is "foo".
load_layers
Read homogeneous native layers after resolving one format for the entire list.
merge
Left-folds layers into one document, starting from an empty object.
merge_into
Merges over into base in place (jq’s a * b).
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
Parses text as a TOML value, falling back to the original text as a string.