pub struct LiteralValue {
pub value: ValueKind,
}Expand description
Runtime literal payload. Type lives on NormalForm.result_type / DataDefinition /
explicit computation parameters — not on the value.
Fields§
§value: ValueKindImplementations§
Source§impl LiteralValue
impl LiteralValue
pub fn text(s: String) -> Self
pub fn number(n: RationalInteger) -> Self
pub fn number_from_decimal(decimal: Decimal) -> Self
pub fn measure(n: RationalInteger) -> Self
Sourcepub fn measure_with_type(
n: RationalInteger,
_lemma_type: Arc<LemmaType>,
) -> Self
pub fn measure_with_type( n: RationalInteger, _lemma_type: Arc<LemmaType>, ) -> Self
Type arg ignored — type lives on the node / caller.
pub fn measure_with_bound_unit( n: RationalInteger, _unit_name: impl Into<String>, _lemma_type: Arc<LemmaType>, ) -> Self
pub fn measure_with_signature( n: RationalInteger, _lemma_type: Arc<LemmaType>, ) -> Self
pub fn number_with_type(n: RationalInteger, _lemma_type: Arc<LemmaType>) -> Self
pub fn number_with_type_from_decimal( decimal: Decimal, _lemma_type: Arc<LemmaType>, ) -> Self
pub fn ratio_with_type(r: RationalInteger, _lemma_type: Arc<LemmaType>) -> Self
pub fn ratio_with_bound_unit( r: RationalInteger, _unit_name: impl Into<String>, _lemma_type: Arc<LemmaType>, ) -> Self
pub fn text_with_type(s: String, _lemma_type: Arc<LemmaType>) -> Self
pub fn date_with_type(dt: SemanticDateTime, _lemma_type: Arc<LemmaType>) -> Self
pub fn time_with_type(t: SemanticTime, _lemma_type: Arc<LemmaType>) -> Self
pub fn calendar( value: RationalInteger, _unit: SemanticCalendarUnit, _lemma_type: Arc<LemmaType>, ) -> Self
pub fn calendar_from_decimal( value: Decimal, unit: SemanticCalendarUnit, lemma_type: Arc<LemmaType>, ) -> Self
pub fn calendar_with_type( value: RationalInteger, unit: SemanticCalendarUnit, lemma_type: Arc<LemmaType>, ) -> Self
pub fn number_interpreted_as_measure( value: RationalInteger, _unit_name: String, ) -> Self
pub fn from_bool(b: bool) -> Self
pub fn from_datetime(dt: &DateTimeValue) -> Self
pub fn date(dt: SemanticDateTime) -> Self
pub fn time(t: SemanticTime) -> Self
pub fn ratio(r: RationalInteger) -> Self
pub fn ratio_from_decimal(r: Decimal) -> Self
pub fn range(left: LiteralValue, right: LiteralValue) -> Self
Sourcepub fn display_value(&self) -> String
pub fn display_value(&self) -> String
Display without an explicit type. Measure/ratio fall back to magnitude-only.
Sourcepub fn display_value_with_type(&self, lemma_type: &LemmaType) -> String
pub fn display_value_with_type(&self, lemma_type: &LemmaType) -> String
Display string given an explicit type (measure/ratio need unit identity).
Sourcepub fn magnitude_suggestion_for_decimal_prompt(
&self,
lemma_type: &LemmaType,
) -> Option<String>
pub fn magnitude_suggestion_for_decimal_prompt( &self, lemma_type: &LemmaType, ) -> Option<String>
Magnitude string for decimal input prompts.
Sourcepub fn measure_units(
&self,
lemma_type: &LemmaType,
) -> Option<BTreeMap<String, String>>
pub fn measure_units( &self, lemma_type: &LemmaType, ) -> Option<BTreeMap<String, String>>
Per-unit magnitudes when this literal is a measure with declared units.
Sourcepub fn ratio_units(
&self,
lemma_type: &LemmaType,
) -> Option<BTreeMap<String, String>>
pub fn ratio_units( &self, lemma_type: &LemmaType, ) -> Option<BTreeMap<String, String>>
Per-unit magnitudes when this literal is a ratio with declared units.
Sourcepub fn magnitude_in_unit(
&self,
lemma_type: &LemmaType,
unit: &str,
) -> Option<String>
pub fn magnitude_in_unit( &self, lemma_type: &LemmaType, unit: &str, ) -> Option<String>
Magnitude in a declared unit when this literal is measure or ratio.
Sourcepub fn duration_canonical_seconds(
&self,
lemma_type: &LemmaType,
) -> RationalInteger
pub fn duration_canonical_seconds( &self, lemma_type: &LemmaType, ) -> RationalInteger
Derive second from a duration measure’s canonical magnitude.
Sourcepub fn calendar_canonical_months(
&self,
lemma_type: &LemmaType,
) -> RationalInteger
pub fn calendar_canonical_months( &self, lemma_type: &LemmaType, ) -> RationalInteger
Derive month from a calendar measure’s canonical magnitude.
Trait Implementations§
Source§impl Clone for LiteralValue
impl Clone for LiteralValue
Source§fn clone(&self) -> LiteralValue
fn clone(&self) -> LiteralValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LiteralValue
impl Debug for LiteralValue
Source§impl<'de> Deserialize<'de> for LiteralValue
impl<'de> Deserialize<'de> for LiteralValue
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for LiteralValue
impl Display for LiteralValue
impl Eq for LiteralValue
Source§impl From<&LiteralValue> for LiteralValue
impl From<&LiteralValue> for LiteralValue
Source§fn from(literal: &DomainLiteralValue) -> Self
fn from(literal: &DomainLiteralValue) -> Self
Converts to this type from the input type.
Source§impl Hash for LiteralValue
impl Hash for LiteralValue
Source§impl PartialEq for LiteralValue
impl PartialEq for LiteralValue
Source§impl Serialize for LiteralValue
impl Serialize for LiteralValue
impl StructuralPartialEq for LiteralValue
Auto Trait Implementations§
impl Freeze for LiteralValue
impl RefUnwindSafe for LiteralValue
impl Send for LiteralValue
impl Sync for LiteralValue
impl Unpin for LiteralValue
impl UnsafeUnpin for LiteralValue
impl UnwindSafe for LiteralValue
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
Mutably borrows from an owned value. Read more
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
Compare self to
key and return true if they are equal.