Skip to main content

Namespace

Struct Namespace 

Source
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: Defs

Collection of normalized defs.

§subtypes: SymbolDefs

Symbol to subtype defs.

§choices: SymbolDefs

Symbols 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: SymbolDefs

A object that maps def names to their respective tagOn defs.

Implementations§

Source§

impl Namespace

Source

pub fn make(defs: Grid) -> Self

Constructs a new namespace

§Arguments
  • defs The normalized defs grid
Source

pub fn get(&self, symbol: &Symbol) -> Option<&Dict>

Return a def via its symbol if it can’t be found.

Source

pub fn get_by_name(&self, name: &str) -> Option<&Dict>

Return a def via its name if it can’t be found.

Source

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

Return true if the def name exists in the namespace.

Source

pub fn has(&self, symbol: &Symbol) -> bool

Return true if the def exists in the namespace.

Source

pub fn all_matching_names(&self, names: &[&str]) -> Vec<&Dict>

Return a list of defs matching the names.

Source

pub fn is_conjunct(symbol: &Symbol) -> bool

True if the name is for a conjunct.

Source

pub fn conjuncts_defs(&self, symbol: &Symbol) -> Vec<&Dict>

Decomposes a conjunct into its respective defs and returns them

Source

pub fn is_feature(symbol: &Symbol) -> bool

True if the name is for a feature.

Source

pub fn subtypes_of(&self, symbol: &Symbol) -> &Vec<Dict>

Returns the subtypes of the type.

Source

pub fn has_subtype(&self, symbol: &Symbol) -> bool

True if the def has subtypes.

Source

pub fn all_subtypes_of(&self, symbol: &Symbol) -> Vec<&Dict>

Returns a flattened list of all the subtypes.

§Arguments
  • symbol The def to get the subtypes of
§Returns

All subtypes

Source

pub fn supertypes_of(&self, symbol: &Symbol) -> Vec<&Dict>

Returns the direct supertypes (immediate is parents) of a def.

Source

pub fn all_supertypes_of(&self, symbol: &Symbol) -> Vec<&Dict>

Returns a flattened list of all the supertypes in the whole supertype chain.

Source

pub fn choices_for(&self, symbol: &Symbol) -> &Vec<Dict>

Returns a list of choices for def.

Source

pub fn inheritance(&self, symbol: &Symbol) -> Vec<&Dict>

Return the defs inheritance as a flattened array of defs (self + all ancestors).

Source

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.
Source

pub fn is(&self, parent: &Symbol) -> Vec<&Dict>

Return a vector of defs for the is association on the parent.

§Arguments
  • parent The parent def
§Return

The is association defs

Source

pub fn tag_on(&self, parent: &Symbol) -> Vec<&Dict>

Return a vector of defs for the tagOn association on the parent.

§Arguments
  • parent The parent def
§Return

The tagOn association defs

Source

pub fn tags(&self, parent: &Symbol) -> Vec<&Dict>

Return a vector of defs for the tags association on the parent.

§Arguments
  • parent The parent def
§Return

The tags association defs

Source

pub fn reflect<'a>(&'a self, subject: &Dict) -> Reflection<'a>

Return the defs implemented by the subject dict.

§Arguments
  • subject The subject to reflect
§Return

The reflected defs

Source

pub fn def_of_dict(&self, subject: &Dict) -> &Dict

Source

pub fn fits(&self, def: &Symbol, base_def: &Symbol) -> bool

Return true if the specified def fits the base def.

If true this means that def is assignable to types of base_def. This is effectively the same as checking if inheritance(def) contains base.

§Arguments
  • def The symbol to check
  • def_base The base definition
§Returns

True if the def fits the base def.

Source

pub fn fits_marker(&self, def: &Symbol) -> bool

Return true if the specified def is a marker.

§Arguments
  • def The symbol to check
§Returns

True if the def is a marker.

Source

pub fn fits_val(&self, def: &Symbol) -> bool

Return true if the specified def is a val.

§Arguments
  • def The symbol to check
§Returns

True if the def is a value.

Source

pub fn fits_choice(&self, def: &Symbol) -> bool

Return true if the specified def is a choice.

§Arguments
  • def The symbol to check
§Returns

True if the def is a choice.

Source

pub fn fits_entity(&self, def: &Symbol) -> bool

Return true if the specified def is a entity.

§Arguments
  • def The symbol to check
§Returns

True if the def is a entity.

Source

pub fn implementation(&self, def: &Symbol) -> Vec<&Dict>

Return the tags that should be added for implementation.

§Arguments
  • name The def name.
§Returns

An array of defs to be added.

Source

pub fn protos(&self, parent: &Dict) -> Vec<Dict>

Return a reflected list of children prototypes for the parent dict.

§Arguments
  • parent The parent dict.
§Returns

A list of children.

Source

pub fn core_type_defs(&self) -> CoreTypeDefs<'_>

The defs for all of the core haystack value types.

Source

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.

Trait Implementations§

Source§

impl Debug for Namespace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Namespace

Source§

fn default() -> Namespace

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V