pub struct LabelRegistry {
pub labels: Vec<Label>,
pub assignments: BTreeMap<String, Vec<String>>,
}Expand description
The whole taxonomy: an ordered list of labels plus fleet → label-ids.
assignments order is meaningful (index 0 is the primary label); the map
itself is a BTreeMap so the serialized file is stable across saves.
Fields§
§labels: Vec<Label>§assignments: BTreeMap<String, Vec<String>>Implementations§
Source§impl LabelRegistry
impl LabelRegistry
pub fn contains(&self, id: &str) -> bool
pub fn get(&self, id: &str) -> Option<&Label>
Sourcepub fn labels_of(&self, fleet: &str) -> &[String]
pub fn labels_of(&self, fleet: &str) -> &[String]
Labels assigned to a fleet, primary first. Empty when unassigned.
Sourcepub fn primary_of(&self, fleet: &str) -> Option<&str>
pub fn primary_of(&self, fleet: &str) -> Option<&str>
The group a fleet belongs to: its first label, or None for Ungrouped.
Sourcepub fn fleet_count(&self, id: &str) -> usize
pub fn fleet_count(&self, id: &str) -> usize
How many fleets carry a label (in any position).
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Self-heal a registry that may have been hand-edited: drop invalid or unknown label ids, de-duplicate while keeping first-wins order (so the primary survives), and drop fleets left with nothing.
Sourcepub fn set_labels(&mut self, fleet: &str, ids: Vec<String>)
pub fn set_labels(&mut self, fleet: &str, ids: Vec<String>)
Replace a fleet’s labels (order = priority; first is primary).
Sourcepub fn delete_label(&mut self, id: &str)
pub fn delete_label(&mut self, id: &str)
Remove a label everywhere: from the list and from every assignment. Fleets fall back to their next label, or become Ungrouped.
Sourcepub fn rename_label(&mut self, id: &str, display: &str) -> bool
pub fn rename_label(&mut self, id: &str, display: &str) -> bool
Rename a label’s display text (the id, being the key, is stable).
Trait Implementations§
Source§impl Clone for LabelRegistry
impl Clone for LabelRegistry
Source§fn clone(&self) -> LabelRegistry
fn clone(&self) -> LabelRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LabelRegistry
impl Debug for LabelRegistry
Source§impl Default for LabelRegistry
impl Default for LabelRegistry
Source§fn default() -> LabelRegistry
fn default() -> LabelRegistry
Source§impl<'de> Deserialize<'de> for LabelRegistry
impl<'de> Deserialize<'de> for LabelRegistry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for LabelRegistry
Source§impl PartialEq for LabelRegistry
impl PartialEq for LabelRegistry
Source§impl Serialize for LabelRegistry
impl Serialize for LabelRegistry
impl StructuralPartialEq for LabelRegistry
Auto Trait Implementations§
impl Freeze for LabelRegistry
impl RefUnwindSafe for LabelRegistry
impl Send for LabelRegistry
impl Sync for LabelRegistry
impl Unpin for LabelRegistry
impl UnsafeUnpin for LabelRegistry
impl UnwindSafe for LabelRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.