Expand description
The comment-preserving writer behind the settings editor.
An edit names a catalogue pattern and the concrete path it fills; the pattern says where the item sits, so a display path with dots in a name is never re-parsed as TOML. One pass applies every edit to the current text, and the caller validates the candidate with the boot loader before it replaces the file.
Re-exportsยง
use forge_primitives::settings::EditKind;๐use forge_primitives::settings::SettingsDocument;๐use forge_primitives::settings::SettingsEdit;๐use forge_primitives::settings::SettingsEditOp;๐use forge_primitives::settings::SettingsEditRequest;๐use forge_primitives::settings::SettingsKey;๐use toml_edit::Array;๐use toml_edit::ArrayOfTables;๐use toml_edit::DocumentMut;๐use toml_edit::InlineTable;๐use toml_edit::Item;๐use toml_edit::Table;๐use toml_edit::Value;๐
Structsยง
- Write
Error ๐ - Why an edit could not be applied.
Enumsยง
- Container ๐
- The container a leafโs parent is: a table, or an inline table
(
model_slugs = { ... }). - Part ๐
- Step ๐
- One step into the document.
Functionsยง
- add_
entry ๐ - Add a whole entry: an account, a project under an org, a Slack workspace, or a model table.
- apply ๐
- Apply every edit to the current text.
- apply_
one ๐ - array_
step ๐ - build ๐
- Turn one set of instance names into steps, and rebuild the path they should produce.
- descend ๐
- descend_
from ๐ - entry_
table ๐ - Apply an entryโs fields to a fresh table.
- find_
key ๐ - identity_
pattern ๐ - The catalogue pattern of an edit when it is one of the fields that names its entry, which a batch must apply after the editโs other changes.
- invalid ๐
- item_
suffix ๐ - The trailing comment a value carries on its own line.
- json_
item ๐ - keep_
prefix ๐ - Put a leftover entryโs comments at the end of the table that held the array, so an only-entry removal keeps them.
- keep_
suffix ๐ - Append text to a tableโs own trailing decor.
- key_
text ๐ - The comments and whitespace a table entryโs key carries before it.
- locate ๐
- Where a leaf sits: the steps to its parent and the leafโs own key.
- locate_
from_ ๐group - The split from the rowโs
group, accepted only when it rebuilds the rowโs own path. - locate_
from_ ๐path - The split read off the rowโs path: each wildcard takes the shortest name that lets the rest of the pattern match, so the patternโs literal segments anchor it.
- match_
path ๐ - Match a pattern against a display path, shortest wildcard names first, and collect the instance names in wildcard order.
- match_
pattern ๐ - Whether
pathfillspattern, and the instance names it took. The catalogueโs own matcher, so a key the config does not set can still be resolved back to the pattern that would write it. - next_
key_ ๐after - The key after
keyin the tableโs own order, before it is removed. - parts_
of ๐ - place_
root_ ๐prefix - Put a departed tableโs comments above the next root entry, or at the documentโs end when it was the last one.
- project_
path ๐ - The org and project a project entry path names, matched against the
documentโs own org names: an org name containing dots (or the literal
.projects.) cannot be cut short by a split. - remove_
entry ๐ - Remove a whole entry.
- remove_
entry_ ๐at - Remove one table from an array of tables, moving its comments onto the entry that follows (or the previous entryโs trailing text when it was last) so a removal does not take the readerโs notes with it. A prefix with nowhere to go - the arrayโs only entry - is handed back for the parent table to carry.
- remove_
key ๐ - remove_
leaf ๐ - set_
item_ ๐value - set_key ๐
- split_
then ๐ - Try each dot boundary of
pathas a wildcard name, shortest first, and keep the name only when the rest of the pattern matches. - strip_
prefix ๐ - to_toml ๐
- Convert a JSON value to the TOML shape its edit kind names.
- validate ๐
- Validate one value against a keyโs edit spec without applying it, so a tool can refuse a wrong type before it asks the reader anything.