pub struct LabelChangeset { /* private fields */ }Expand description
An in-memory, deterministic collection of BIP-329 wallet labels.
Backed by a BTreeMap, this structure ensures $O(\log n)$ deduplication and
guarantees that labels are deterministically sorted by their reference key.
This prevents noisy diffs when exporting to version-controlled JSONL files.
Implementations§
Source§impl LabelChangeset
impl LabelChangeset
Sourcepub fn insert(&mut self, label: Label)
pub fn insert(&mut self, label: Label)
Inserts a new label into the changeset making its ref staged. If a label with the same reference already exists, it is overwritten.
Sourcepub fn remove(&mut self, target: &LabelRef) -> Option<Label>
pub fn remove(&mut self, target: &LabelRef) -> Option<Label>
Removes the label associated with the given target reference, returning it if it existed.
Sourcepub fn get(&self, target: &LabelRef) -> Option<&Label>
pub fn get(&self, target: &LabelRef) -> Option<&Label>
Retrieves a reference to the label associated with the given target.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Label>
pub fn iter(&self) -> impl Iterator<Item = &Label>
Returns an iterator over the labels, yielded in deterministic order based on their reference.
Sourcepub fn merge(&mut self, incoming: LabelChangeset, strategy: MergeStrategy)
pub fn merge(&mut self, incoming: LabelChangeset, strategy: MergeStrategy)
Merges an incoming LabelChangeset into the current one, resolving conflicts based on the provided MergeStrategy.
Sourcepub fn diff(&self) -> LabelChangeset
pub fn diff(&self) -> LabelChangeset
Returns the unpersisted diff of the changeset.
Sourcepub fn clear_staged(&mut self)
pub fn clear_staged(&mut self)
Clears the staged label refs
Sourcepub fn has_staged_changes(&self) -> bool
pub fn has_staged_changes(&self) -> bool
Checks and returns true if there are changes staged
Trait Implementations§
Source§impl Clone for LabelChangeset
impl Clone for LabelChangeset
Source§fn clone(&self) -> LabelChangeset
fn clone(&self) -> LabelChangeset
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more