pub struct LemmaType {
pub name: Option<String>,
pub specifications: TypeSpecification,
}Expand description
A fully resolved type used during evaluation
This combines the type specifications with all overrides already applied.
Fields§
§name: Option<String>§specifications: TypeSpecificationImplementations§
Source§impl LemmaType
impl LemmaType
Sourcepub fn new(name: String, specifications: TypeSpecification) -> Self
pub fn new(name: String, specifications: TypeSpecification) -> Self
Create a new LemmaType with the given name and specifications
Sourcepub fn without_name(specifications: TypeSpecification) -> Self
pub fn without_name(specifications: TypeSpecification) -> Self
Create a new LemmaType without a name (for standard types and inline fact definitions)
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Get the name of this type, deriving from specifications if name is None
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 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 standard type specification (ignoring constraints/overrides) This compares only the TypeSpecification variant (Boolean, Number, Scale, Text, etc.) and ignores all constraints like minimum, maximum, decimals, units, options, etc.
Sourcepub fn create_default_value(&self) -> Option<LiteralValue>
pub fn create_default_value(&self) -> Option<LiteralValue>
Create a LiteralValue from this type’s default value, if one exists
Sourcepub fn parse_value(
&self,
raw: &str,
span: Span,
attribute: &str,
doc_name: &str,
) -> Result<LiteralValue, LemmaError>
pub fn parse_value( &self, raw: &str, span: Span, attribute: &str, doc_name: &str, ) -> Result<LiteralValue, LemmaError>
Parse a raw string value into a LiteralValue according to this type.
Parsing errors are anchored to the provided source location (span, attribute, doc_name).
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 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> 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 more