Expand description
Strongly typed KDL configuration with derive-based decoding, canonical rendering, validation, fragments, layered loading, and round-trip updates.
Most consumers derive KdlNode and call parse_str:
use kdl_config::{KdlNode, parse_str};
#[derive(Debug, KdlNode)]
#[kdl(node = "server")]
struct Server {
#[kdl(attr)]
host: String,
#[kdl(attr)]
port: u16,
}
let server: Server = parse_str(r#"server host="localhost" port=8080"#)?;
assert_eq!(server.port, 8080);Re-exports§
pub use newtypes::Duration;pub use newtypes::Identifier;pub use newtypes::LenientIdentifier;pub use newtypes::PositiveCount;pub use newtypes::Scalar;pub use newtypes::Weight;pub use validation::AsF64;pub use validation::KdlContains;pub use validation::KdlSubsetOf;pub use validation::KdlValidate;pub use validation::KdlValidateCount;pub use validation::run_count_validations;pub use validation::run_cross_field_validation;pub use validation::run_exists_in_validation;pub use validation::run_field_validations;pub use validation::run_func_validation;pub use validation::run_subset_of_validation;pub use validation::run_typed_cross_field_validation;pub use config::BoolMode;pub use config::ConflictPolicy;pub use config::DefaultPlacement;pub use config::EffectiveConfig;pub use config::FieldOverrides;pub use config::FlagStyle;pub use config::FragmentSyntax;pub use config::ParseConfig;pub use config::RootMode;pub use config::StructOverrides;pub use config::resolve_field;pub use config::resolve_struct;pub use context::DecodeContext;pub use context::Source;pub use context::UpdateContext;pub use convert::ConvertContext;pub use convert::FromKdlValue;pub use convert::ValueConvertExt;pub use convert::convert_value;pub use convert::convert_value_checked;pub use convert::convert_value_checked_ctx;pub use convert::convert_value_ctx;pub use error::ErrorKind;pub use error::KdlConfigError;pub use error::NodeLocation;pub use error::Placement;pub use formatter::KdlFormatter;pub use fragments::FragmentExpansion;pub use node_ext::KdlNodeExt;pub use node_ext::arg_entry_index;pub use node_ext::attr_entry_indices;pub use node_ext::remove_attr_entries;pub use node_ext::remove_entry_indices;pub use node_ext::remove_positional_entry;pub use node_ext::update_entry_from_value;pub use node_ext::update_entry_value;pub use node_ext::update_or_insert_attr;pub use node_ext::update_or_insert_attr_value;pub use node_ext::update_or_insert_positional;pub use node_ext::update_or_insert_positional_value;pub use node_path::NodePath;pub use parse::parse_config;pub use parse::parse_config_with_config;pub use parse::parse_node;pub use parse::parse_node_with_config;pub use render::NodeRenderer;pub use render::escape_string;pub use render::insert_arg;pub use render::insert_attr;pub use render::is_valid_identifier;pub use render::new_kdl_node;pub use render::new_kdl_node_with_config;pub use render::render_child_node;pub use render::render_flatten;pub use render::render_key;pub use render::render_key_with_repr;pub use render::render_node;pub use render::render_node_name;pub use render::render_node_name_with_config;pub use render::render_node_name_with_repr;pub use render::render_node_name_with_repr_and_config;pub use render::render_node_with_config;pub use render::render_value;pub use render::render_value_node;pub use render::render_value_node_scalar;pub use render::render_value_with_repr;pub use render::replace_node_name;pub use render::set_kdl_node_name;pub use render::set_kdl_node_name_with_config;pub use render::value_node;pub use render::value_to_kdl;pub use render::value_to_kdl_entry;pub use render::value_to_kdl_values;pub use render::write_indent;pub use resolve::decode_at;pub use resolve::decode_at_with_config;pub use resolve::node_at;pub use round_trip::RoundTripAst;pub use round_trip::parse_file_roundtrip;pub use round_trip::parse_file_roundtrip_with_config;pub use round_trip::parse_str_roundtrip;pub use round_trip::parse_str_roundtrip_with_config;pub use selector::CollectMode;pub use selector::CollectionSpec;pub use selector::InjectOpt;pub use selector::SelectOpts;pub use selector::SelectSpec;pub use selector::SelectorAst;pub use types::FieldOrder;pub use types::MergeModifierPolicy;pub use types::Modifier;pub use types::Node;pub use types::NodeLocation as NodeLocationLegacy;pub use types::Value;pub use kdl;
Modules§
- config
- context
- convert
- error
- formatter
- KDL formatting helpers for updating top-level blocks.
- fragments
- helpers
- layer
- Layered configuration utilities.
- loader
- KDL configuration loading utilities.
- merge
- newtypes
- node_
ext - node_
path - parse
- render
- resolve
- round_
trip - schema
- selector
- types
- validation
Structs§
- KdlDocument
- Represents a KDL
Document. - KdlEntry
- KDL Entries are the “arguments” to KDL nodes: either a (positional)
Argumentor a (key/value)Property - KdlNode
- Represents an individual KDL
Nodeinside a KDL Document.
Enums§
Traits§
- KdlDecode
- Trait for decoding a typed configuration from a KDL Node.
- KdlEncode
- Trait for encoding a value into a new KDL Node (canonical rendering).
- KdlRender
- Trait for rendering a value into KDL.
- KdlUpdate
- Trait for updating an existing KDL Node in-place (AST-preserving).
Functions§
- expand_
fragments - Expand fragments in a parsed KDL document using the default sigil syntax.
- expand_
fragments_ with_ config - Expand fragments in a parsed KDL document using
config. - parse_
file - Parse a typed KDL file using
ParseConfig::default. - parse_
file_ with_ config - Parse a typed KDL file, resolving
@importrelative to that file. - parse_
str - Parse a KDL string into a typed configuration using default config.
- parse_
str_ with_ config - Parse a KDL string into a typed configuration using the provided config.
- to_kdl
- Render a KDL value into a string.
- to_
kdl_ document - Render a KDL value into a flat document, i.e. as the children of the
implicit wrapper node
namerather than as aname { ... }block. - to_
kdl_ document_ with_ config - Render a flat KDL document using the selected fragment language.
- to_
kdl_ with_ config - Render a KDL value using the selected fragment language.