pub struct EntryTree { /* private fields */ }Expand description
An in-memory tree of Entrys mirroring one config file.
Entries are addressed by id; nested entries use composite ids
(outer:inner, see Entry::path). Entries without an explicit id get
a random 6-character base36 id that is persisted on the next write-back.
Structural edits are serialized through an internal lock; individual
reads (children, parent walks) take per-entry locks. EntryTree is not
bound to any file — pairing it with a crate::LoaderFile is the
caller’s (usually the loader’s) job.
Implementations§
Source§impl EntryTree
impl EntryTree
Sourcepub fn root(&self) -> &Entry
pub fn root(&self) -> &Entry
The synthetic root holding the top-level entries. It is addressed by
the empty id and never returned by EntryTree::resolve.
Sourcepub fn resolve(&self, id: &str) -> Option<Entry>
pub fn resolve(&self, id: &str) -> Option<Entry>
Look an entry up by (possibly composite) id, e.g. group1:child2.
Sourcepub fn serialize(&self) -> Vec<EntryOptions>
pub fn serialize(&self) -> Vec<EntryOptions>
Serialize the whole tree back to options, generated ids included.
Sourcepub fn create(
&self,
options: EntryOptions,
parent: Option<&Entry>,
position: Option<usize>,
) -> Result<Entry, IncludeError>
pub fn create( &self, options: EntryOptions, parent: Option<&Entry>, position: Option<usize>, ) -> Result<Entry, IncludeError>
Create an entry below parent (the tree root when None) at
position (appended when None). options.group seeds the child
list for group entries. Returns the created entry.
Sourcepub fn remove(&self, id: &str) -> Result<Entry, IncludeError>
pub fn remove(&self, id: &str) -> Result<Entry, IncludeError>
Detach the entry with the given id and return it with its subtree intact, so the loader can still stop the fibers inside it.
Sourcepub fn update_entry(
&self,
id: &str,
options: EntryOptions,
new_parent: Option<&Entry>,
position: Option<usize>,
) -> Result<Entry, IncludeError>
pub fn update_entry( &self, id: &str, options: EntryOptions, new_parent: Option<&Entry>, position: Option<usize>, ) -> Result<Entry, IncludeError>
Update one entry’s options and optionally move it below
new_parent (appended unless position is given). The entry id is
identity and survives the update; options.id is ignored.
options.group re-syncs the entry’s children, reusing existing
subtree entries whose ids match.
Sourcepub fn update(
&self,
entries: Vec<EntryOptions>,
) -> Result<TreeDiff, IncludeError>
pub fn update( &self, entries: Vec<EntryOptions>, ) -> Result<TreeDiff, IncludeError>
Reload the whole tree from new options, reusing existing entries wherever ids match — including entries that moved between groups — and returning what changed.
Entries in the new data without an id cannot be matched and are
always created fresh; persist generated ids by writing
EntryTree::serialize back to the file.