Skip to main content

TaxonomyTree

Struct TaxonomyTree 

Source
pub struct TaxonomyTree { /* private fields */ }
Expand description

Unified inheritance graph for Haystack 4 defs.

Supports multiple inheritance (a def can have multiple supertypes via the is tag). Pre-computes mandatory marker sets on first access for fast fits() evaluation.

Implementations§

Source§

impl TaxonomyTree

Source

pub fn new() -> Self

Create an empty taxonomy tree.

Source

pub fn add(&mut self, name: &str, supertypes: &[String])

Register a type with its supertypes.

Source

pub fn is_subtype(&self, child: &str, parent: &str) -> bool

Check if child is a subtype of parent.

Uses BFS up the parent chain. Returns true if child equals parent or if parent is an ancestor.

Source

pub fn supertypes_of(&self, name: &str) -> Vec<String>

Full ancestor chain (transitive, breadth-first).

Returns all ancestors of name, nearest first.

Source

pub fn subtypes_of(&self, name: &str) -> Vec<String>

Direct children of a type.

Source

pub fn all_subtypes(&self, name: &str) -> Vec<String>

All descendants (transitive, breadth-first).

Source

pub fn mandatory_tags( &self, name: &str, mandatory_defs: &HashSet<String>, ) -> HashSet<String>

Get mandatory marker tags for a type.

Walks the supertype chain and collects all types that are marked as mandatory. Results are cached.

Source

pub fn contains(&self, name: &str) -> bool

Check if a type is registered in the taxonomy.

Source

pub fn len(&self) -> usize

Number of registered types.

Source

pub fn is_empty(&self) -> bool

Returns true if no types are registered.

Source

pub fn clear_cache(&self)

Clear the mandatory tag cache (used after library unload).

Trait Implementations§

Source§

impl Default for TaxonomyTree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.