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: TypeSpecificationThe 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: TypeExtendsWhat this type extends (primitive or custom from a spec)
Implementations§
Source§impl LemmaType
impl LemmaType
Sourcepub fn map_quantity<F>(self, f: F) -> Self
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.
Sourcepub fn new(
name: String,
specifications: TypeSpecification,
extends: TypeExtends,
) -> Self
pub fn new( name: String, specifications: TypeSpecification, extends: TypeExtends, ) -> Self
Create a new type with a name
Sourcepub fn without_name(
specifications: TypeSpecification,
extends: TypeExtends,
) -> Self
pub fn without_name( specifications: TypeSpecification, extends: TypeExtends, ) -> Self
Create a type without a name (anonymous/inline type)
Sourcepub fn primitive(specifications: TypeSpecification) -> Self
pub fn primitive(specifications: TypeSpecification) -> Self
Create a primitive type (no name, extends Primitive)
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Check if this type is boolean
pub fn matches_primitive_kind(&self, kind: PrimitiveKind) -> bool
Sourcepub fn is_quantity(&self) -> bool
pub fn is_quantity(&self) -> bool
Check if this type is quantity
pub fn is_quantity_range(&self) -> bool
pub fn is_number_range(&self) -> bool
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Check if this type is numeric (either quantity or number)
pub fn is_date_range(&self) -> bool
pub fn is_time_range(&self) -> bool
pub fn has_trait_duration(&self) -> bool
pub fn is_duration_like_quantity(&self) -> bool
pub fn is_duration_like(&self) -> bool
pub fn has_trait_calendar(&self) -> bool
pub fn is_calendar_like_quantity(&self) -> bool
pub fn is_calendar_like(&self) -> bool
pub fn is_ratio_range(&self) -> bool
pub fn is_calendar_quantity_range(&self) -> bool
pub fn is_calendar_like_range(&self) -> bool
pub fn is_range(&self) -> bool
Sourcepub fn is_undetermined(&self) -> bool
pub fn is_undetermined(&self) -> bool
True if this type is the undetermined sentinel (type could not be inferred).
Sourcepub fn has_same_base_type(&self, other: &LemmaType) -> bool
pub fn has_same_base_type(&self, other: &LemmaType) -> bool
Check if two types have the same base type specification (ignoring constraints)
Sourcepub fn quantity_family_name(&self) -> Option<&str>
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.
Sourcepub fn same_quantity_family(&self, other: &LemmaType) -> bool
pub fn same_quantity_family(&self, other: &LemmaType) -> bool
Returns true if both types are quantity and belong to the same named quantity family.
pub fn compatible_with_anonymous_quantity(&self, other: &LemmaType) -> bool
Sourcepub fn undetermined_type() -> Self
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.
Sourcepub fn decimal_places(&self) -> Option<u8>
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).
Sourcepub fn try_materialize_rational_as_decimal_string(
&self,
magnitude: &RationalInteger,
) -> Result<String, NumericFailure>
pub fn try_materialize_rational_as_decimal_string( &self, magnitude: &RationalInteger, ) -> Result<String, NumericFailure>
Commit a rational magnitude to a decimal string for API materialization.
Applies this type’s decimal_places when set. Returns [NumericFailure] when the
magnitude cannot commit to rust_decimal (callers map this to a decimal-limit Veto).
Sourcepub fn try_materialize_quantity_canonical_in_unit(
&self,
canonical_magnitude: &RationalInteger,
unit_name: &str,
) -> Result<String, NumericFailure>
pub fn try_materialize_quantity_canonical_in_unit( &self, canonical_magnitude: &RationalInteger, unit_name: &str, ) -> Result<String, NumericFailure>
Commit a canonical quantity magnitude in the named declared unit for API materialization.
Sourcepub fn try_materialize_ratio_canonical_in_unit(
&self,
canonical_magnitude: &RationalInteger,
unit_name: &str,
) -> Result<String, NumericFailure>
pub fn try_materialize_ratio_canonical_in_unit( &self, canonical_magnitude: &RationalInteger, unit_name: &str, ) -> Result<String, NumericFailure>
Commit a canonical ratio magnitude in the named declared unit for API materialization.
Sourcepub fn example_value(&self) -> &'static str
pub fn example_value(&self) -> &'static str
Get an example value string for this type, suitable for UI help text
Sourcepub fn quantity_type_decomposition(&self) -> Option<&BTreeMap<String, i32>>
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.
Sourcepub fn is_anonymous_quantity(&self) -> bool
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.
Sourcepub fn anonymous_for_decomposition(decomposition: BTreeMap<String, i32>) -> Self
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.
Sourcepub fn quantity_unit_names(&self) -> Option<Vec<&str>>
pub fn quantity_unit_names(&self) -> Option<Vec<&str>>
Declared unit names when the type carries a non-empty unit table (None otherwise).
Sourcepub fn quantity_unit_factor(&self, unit_name: &str) -> &RationalInteger
pub fn quantity_unit_factor(&self, unit_name: &str) -> &RationalInteger
Return the conversion factor for a declared unit name on this quantity type.
pub fn ratio_unit_factor(&self, unit_name: &str) -> &RationalInteger
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LemmaType
impl<'de> Deserialize<'de> for LemmaType
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 LemmaType
impl StructuralPartialEq for LemmaType
Auto Trait Implementations§
impl Freeze for LemmaType
impl RefUnwindSafe for LemmaType
impl Send for LemmaType
impl Sync for LemmaType
impl Unpin for LemmaType
impl UnsafeUnpin for LemmaType
impl UnwindSafe for LemmaType
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
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.