pub fn set_nested_mapping(
doc: Document,
parent_path: &[&str],
value_pairs: &[(&str, &str)],
) -> Result<Document>Expand description
Insert or replace a nested mapping at the given parent path.
parent_path is a sequence of mapping keys descending from the root.
All but the last key must resolve to a mapping that the helper can
either find in the source or create alongside its existing siblings.
The last key (the leaf) is the mapping the caller wants to upsert.
value_pairs becomes the body of that leaf mapping.
Existing siblings of the leaf — and existing siblings of any
intermediate the helper has to create — are preserved with their
comments and ordering intact. If the leaf mapping already exists,
it is replaced wholesale by value_pairs. Other adapters under the
same parent (e.g. discord: next to telegram:) survive.
§Errors
Returns an error if parent_path is empty or if the first key is
not a top-level mapping in the document.