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 and TypeDef in the AST.

Fields§

§name: Option<String>

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

§specifications: TypeSpecification

The type specification (Boolean, Number, Scale, etc.)

§extends: TypeExtends

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

Implementations§

Source§

impl LemmaType

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 is_scale(&self) -> bool

Check if this type is scale

Source

pub fn is_number(&self) -> bool

Check if this type is number (dimensionless)

Source

pub fn is_numeric(&self) -> bool

Check if this type is numeric (either scale 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_time(&self) -> bool

Check if this type is time

Source

pub fn is_duration(&self) -> bool

Check if this type is duration

Source

pub fn is_ratio(&self) -> bool

Check if this type is ratio

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

Source

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.

Source

pub fn create_default_value(&self) -> Option<LiteralValue>

Create a default value from this type’s default constraint (if any)

Source

pub fn veto_type() -> Self

Create a Veto LemmaType (internal use only - not user-declarable)

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, Scale, 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 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 Clone for LemmaType

Source§

fn clone(&self) -> LemmaType

Returns a duplicate of the value. Read more
1.0.0 · 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 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 · 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 Eq for LemmaType

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<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> Same for T

Source§

type Output = T

Should always be Self
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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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

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