pub struct Namespace {
pub defs: Defs,
pub subtypes: SymbolDefs,
pub choices: SymbolDefs,
pub conjuncts: Vec<Dict>,
pub conjuncts_keys: BTreeMap<String, Vec<Vec<String>>>,
pub features: Vec<Dict>,
pub libs: Vec<Dict>,
pub feature_names: Vec<String>,
pub tag_on_names: Vec<String>,
pub tag_on_defs: SymbolDefs,
/* private fields */
}Expand description
The container of the normalized definitions.
Fields§
§defs: DefsCollection of normalized defs.
subtypes: SymbolDefsSymbol to subtype defs.
choices: SymbolDefsSymbols to subtypes for all defs that are choices.
conjuncts: Vec<Dict>A list of all available conjunct defs.
conjuncts_keys: BTreeMap<String, Vec<Vec<String>>>§features: Vec<Dict>A list of feature defs.
libs: Vec<Dict>A list of all the libs implemented by this namespace.
feature_names: Vec<String>§tag_on_names: Vec<String>A list of all the tagOn names.
tag_on_defs: SymbolDefsA object that maps def names to their respective tagOn defs.
Implementations§
Source§impl Namespace
impl Namespace
Sourcepub fn get(&self, symbol: &Symbol) -> Option<&Dict>
pub fn get(&self, symbol: &Symbol) -> Option<&Dict>
Return a def via its symbol if it can’t be found.
Sourcepub fn get_by_name(&self, name: &str) -> Option<&Dict>
pub fn get_by_name(&self, name: &str) -> Option<&Dict>
Return a def via its name if it can’t be found.
Sourcepub fn has_name(&self, name: &str) -> bool
pub fn has_name(&self, name: &str) -> bool
Return true if the def name exists in the namespace.
Sourcepub fn all_matching_names(&self, names: &[&str]) -> Vec<&Dict>
pub fn all_matching_names(&self, names: &[&str]) -> Vec<&Dict>
Return a list of defs matching the names.
Sourcepub fn is_conjunct(symbol: &Symbol) -> bool
pub fn is_conjunct(symbol: &Symbol) -> bool
True if the name is for a conjunct.
Sourcepub fn conjuncts_defs(&self, symbol: &Symbol) -> Vec<&Dict>
pub fn conjuncts_defs(&self, symbol: &Symbol) -> Vec<&Dict>
Decomposes a conjunct into its respective defs and returns them
Sourcepub fn is_feature(symbol: &Symbol) -> bool
pub fn is_feature(symbol: &Symbol) -> bool
True if the name is for a feature.
Sourcepub fn subtypes_of(&self, symbol: &Symbol) -> &Vec<Dict>
pub fn subtypes_of(&self, symbol: &Symbol) -> &Vec<Dict>
Returns the subtypes of the type.
Sourcepub fn has_subtype(&self, symbol: &Symbol) -> bool
pub fn has_subtype(&self, symbol: &Symbol) -> bool
True if the def has subtypes.
Sourcepub fn all_subtypes_of(&self, symbol: &Symbol) -> Vec<&Dict>
pub fn all_subtypes_of(&self, symbol: &Symbol) -> Vec<&Dict>
Sourcepub fn supertypes_of(&self, symbol: &Symbol) -> Vec<&Dict>
pub fn supertypes_of(&self, symbol: &Symbol) -> Vec<&Dict>
Returns the direct supertypes (immediate is parents) of a def.
Sourcepub fn all_supertypes_of(&self, symbol: &Symbol) -> Vec<&Dict>
pub fn all_supertypes_of(&self, symbol: &Symbol) -> Vec<&Dict>
Returns a flattened list of all the supertypes in the whole supertype chain.
Sourcepub fn choices_for(&self, symbol: &Symbol) -> &Vec<Dict>
pub fn choices_for(&self, symbol: &Symbol) -> &Vec<Dict>
Returns a list of choices for def.
Sourcepub fn inheritance(&self, symbol: &Symbol) -> Vec<&Dict>
pub fn inheritance(&self, symbol: &Symbol) -> Vec<&Dict>
Return the defs inheritance as a flattened array of defs (self + all ancestors).
Sourcepub fn associations(&self, parent: &Symbol, association: &Symbol) -> Vec<&Dict>
pub fn associations(&self, parent: &Symbol, association: &Symbol) -> Vec<&Dict>
Return a list of defs for the given association on the parent.
§Arguments
- parent The parent def.
- association The association.
Sourcepub fn reflect<'a>(&'a self, subject: &Dict) -> Reflection<'a>
pub fn reflect<'a>(&'a self, subject: &Dict) -> Reflection<'a>
pub fn def_of_dict(&self, subject: &Dict) -> &Dict
Sourcepub fn fits_marker(&self, def: &Symbol) -> bool
pub fn fits_marker(&self, def: &Symbol) -> bool
Sourcepub fn fits_choice(&self, def: &Symbol) -> bool
pub fn fits_choice(&self, def: &Symbol) -> bool
Sourcepub fn fits_entity(&self, def: &Symbol) -> bool
pub fn fits_entity(&self, def: &Symbol) -> bool
Sourcepub fn implementation(&self, def: &Symbol) -> Vec<&Dict>
pub fn implementation(&self, def: &Symbol) -> Vec<&Dict>
Sourcepub fn core_type_defs(&self) -> CoreTypeDefs<'_>
pub fn core_type_defs(&self) -> CoreTypeDefs<'_>
The defs for all of the core haystack value types.
Sourcepub fn has_relationship<F: Fn(&Ref) -> Option<Dict>>(
&self,
subject: &Dict,
rel_name: &Symbol,
rel_term: &Option<Symbol>,
ref_target: &Option<Ref>,
resolve: &F,
) -> bool
pub fn has_relationship<F: Fn(&Ref) -> Option<Dict>>( &self, subject: &Dict, rel_name: &Symbol, rel_term: &Option<Symbol>, ref_target: &Option<Ref>, resolve: &F, ) -> bool
Query a subject’s relationship.
Relationships model how entities are related to one another via instance to instance relationships versus def to def associations.
https://project-haystack.dev/doc/docHaystack/Relationships#querying
§Arguments
- subject The subject dict being queried.
- rel_name The name of the relationship to query.
- rel_term An optional relationship term to query against.
- target_ref An optional reference target.
- resolve An optional function that can resolve dicts (records) from a ref.
§Returns
True if a match is made.