Skip to main content

LemmaType

Struct LemmaType 

Source
pub struct LemmaType {
    pub name: Option<String>,
    pub specifications: TypeSpecification,
    pub extends: TypeExtends,
}
Expand description

Resolved type after planning

Contains a type specification and optional name. Created during planning from TypeSpecification in the AST.

Fields§

§name: Option<String>

Optional type name (e.g., “age”, “temperature”)

§specifications: TypeSpecification

The type specification (Boolean, Number, Quantity, etc.). Serialized as a discriminated union: the variant tag appears as "kind" alongside name and extends, and the variant’s fields are flattened to the top level.

§extends: TypeExtends

What this type extends (primitive or custom from a spec)

Implementations§

Source§

impl LemmaType

Source

pub fn map_quantity<F>(self, f: F) -> Self

Functional update of the Quantity payload (units + decomposition). Non-Quantity variants pass through unchanged. The transform receives the owned units and decomposition and returns the replacements.

Source

pub fn new( name: String, specifications: TypeSpecification, extends: TypeExtends, ) -> Self

Create a new type with a name

Source

pub fn without_name( specifications: TypeSpecification, extends: TypeExtends, ) -> Self

Create a type without a name (anonymous/inline type)

Source

pub fn primitive(specifications: TypeSpecification) -> Self

Create a primitive type (no name, extends Primitive)

Source

pub fn name(&self) -> String

Get the type name, or a default based on the type specification

Source

pub fn is_boolean(&self) -> bool

Check if this type is boolean

Source

pub fn matches_primitive_kind(&self, kind: PrimitiveKind) -> bool

Source

pub fn is_quantity(&self) -> bool

Check if this type is quantity

Source

pub fn is_quantity_range(&self) -> bool

Source

pub fn is_number(&self) -> bool

Check if this type is number (dimensionless)

Source

pub fn is_number_range(&self) -> bool

Source

pub fn is_numeric(&self) -> bool

Check if this type is numeric (either quantity or number)

Source

pub fn is_text(&self) -> bool

Check if this type is text

Source

pub fn is_date(&self) -> bool

Check if this type is date

Source

pub fn is_date_range(&self) -> bool

Source

pub fn is_time_range(&self) -> bool

Source

pub fn is_time(&self) -> bool

Check if this type is time

Source

pub fn has_trait_duration(&self) -> bool

Source

pub fn is_duration_like_quantity(&self) -> bool

Source

pub fn is_duration_like(&self) -> bool

Source

pub fn has_trait_calendar(&self) -> bool

Source

pub fn is_calendar_like_quantity(&self) -> bool

Source

pub fn is_calendar_like(&self) -> bool

Source

pub fn is_ratio(&self) -> bool

Check if this type is ratio

Source

pub fn is_ratio_range(&self) -> bool

Source

pub fn is_calendar_quantity_range(&self) -> bool

Source

pub fn is_calendar_like_range(&self) -> bool

Source

pub fn is_range(&self) -> bool

Source

pub fn vetoed(&self) -> bool

Check if this type is veto

Source

pub fn is_undetermined(&self) -> bool

True if this type is the undetermined sentinel (type could not be inferred).

Source

pub fn has_same_base_type(&self, other: &LemmaType) -> bool

Check if two types have the same base type specification (ignoring constraints)

Source

pub fn quantity_family_name(&self) -> Option<&str>

For quantity types, returns the family name (root of the extension chain). For Custom extends, returns the family field; for Primitive, returns the type’s own name (the type is the root). For non-quantity types, returns None.

Source

pub fn same_quantity_family(&self, other: &LemmaType) -> bool

Returns true if both types are quantity and belong to the same named quantity family.

Source

pub fn compatible_with_anonymous_quantity(&self, other: &LemmaType) -> bool

Source

pub fn veto_type() -> Self

Create a Veto LemmaType

Source

pub fn undetermined_type() -> Self

LemmaType sentinel for undetermined type (used during inference when a type cannot be determined). Propagates through expressions and is never present in a validated graph.

Source

pub fn decimal_places(&self) -> Option<u8>

Decimal places for display (Number, Quantity, and Ratio). Used by formatters. Ratio: optional, no default; when None display is normalized (no trailing zeros).

Source

pub fn example_value(&self) -> &'static str

Get an example value string for this type, suitable for UI help text

Source

pub fn quantity_type_decomposition(&self) -> Option<&BTreeMap<String, i32>>

Factor for a unit of this quantity type (for unit conversion during evaluation only). Planning must validate conversions first and return Error for invalid units. If called with a non-quantity type or unknown unit name, panics (invariant violation). Returns the resolved BaseQuantityVector for Quantity types, or None if the decomposition pass has not yet resolved this type. Panics if called on non-Quantity types.

Source

pub fn is_anonymous_quantity(&self) -> bool

Returns true if this is an anonymous (no-name) Quantity — i.e. an anonymous intermediate produced by cross-axis arithmetic.

Source

pub fn anonymous_for_decomposition(decomposition: BTreeMap<String, i32>) -> Self

Build an anonymous LemmaType for a given dimensional decomposition. Used at plan time to represent the inferred type of cross-axis intermediates. Signatures live on the value, not on the type.

Source

pub fn quantity_unit_names(&self) -> Option<Vec<&str>>

Declared unit names when the type carries a non-empty unit table (None otherwise).

Source

pub fn quantity_unit_factor(&self, unit_name: &str) -> &Ratio<i128>

Return the conversion factor for a declared unit name on this quantity type.

Source

pub fn ratio_unit_factor(&self, unit_name: &str) -> &Ratio<i128>

Trait Implementations§

Source§

impl Clone for LemmaType

Source§

fn clone(&self) -> LemmaType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LemmaType

Source§

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

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

impl<'de> Deserialize<'de> for LemmaType

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for LemmaType

Source§

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

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

impl Eq for LemmaType

Source§

impl Hash for LemmaType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for LemmaType

Source§

fn eq(&self, other: &LemmaType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for LemmaType

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for LemmaType

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more