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 and TypeDef in the AST.
Fields§
§name: Option<String>Optional type name (e.g., “age”, “temperature”)
specifications: TypeSpecificationThe type specification (Boolean, Number, Scale, etc.)
extends: TypeExtendsWhat this type extends (primitive or custom from a spec)
Implementations§
Source§impl LemmaType
impl LemmaType
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
Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Check if this type is numeric (either scale or number)
Sourcepub fn is_duration(&self) -> bool
pub fn is_duration(&self) -> bool
Check if this type is duration
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 scale_family_name(&self) -> Option<&str>
pub fn scale_family_name(&self) -> Option<&str>
For scale 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-scale types, returns None.
Sourcepub fn same_scale_family(&self, other: &LemmaType) -> bool
pub fn same_scale_family(&self, other: &LemmaType) -> bool
Returns true if both types are scale and belong to the same scale family (same family name). Two anonymous primitive scales (no name, no family) are considered compatible.
Sourcepub fn create_default_value(&self) -> Option<LiteralValue>
pub fn create_default_value(&self) -> Option<LiteralValue>
Create a default value from this type’s default constraint (if any)
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, Scale, and Ratio). Used by formatters. Ratio: optional, no default; when None display is normalized (no trailing zeros).
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 scale_unit_factor(&self, unit_name: &str) -> Decimal
pub fn scale_unit_factor(&self, unit_name: &str) -> Decimal
Factor for a unit of this scale type (for unit conversion during evaluation only). Planning must validate conversions first and return Error for invalid units. If called with a non-scale type or unknown unit name, panics (invariant violation).
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,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.