Skip to main content

Module settings_write

Module settings_write 

Source
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ยง

WriteError ๐Ÿ”’
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 path fills pattern, 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 key in 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 path as 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.