Skip to main content

LiteralValue

Struct LiteralValue 

Source
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: ValueKind

Implementations§

Source§

impl LiteralValue

Source

pub fn new(value: ValueKind) -> Self

Source§

impl LiteralValue

Source

pub fn text(s: String) -> Self

Source

pub fn number(n: RationalInteger) -> Self

Source

pub fn number_from_decimal(decimal: Decimal) -> Self

Source

pub fn measure(n: RationalInteger) -> Self

Source

pub fn measure_with_type( n: RationalInteger, _lemma_type: Arc<LemmaType>, ) -> Self

Type arg ignored — type lives on the node / caller.

Source

pub fn measure_with_bound_unit( n: RationalInteger, _unit_name: impl Into<String>, _lemma_type: Arc<LemmaType>, ) -> Self

Source

pub fn measure_with_signature( n: RationalInteger, _lemma_type: Arc<LemmaType>, ) -> Self

Source

pub fn number_with_type(n: RationalInteger, _lemma_type: Arc<LemmaType>) -> Self

Source

pub fn number_with_type_from_decimal( decimal: Decimal, _lemma_type: Arc<LemmaType>, ) -> Self

Source

pub fn ratio_with_type(r: RationalInteger, _lemma_type: Arc<LemmaType>) -> Self

Source

pub fn ratio_with_bound_unit( r: RationalInteger, _unit_name: impl Into<String>, _lemma_type: Arc<LemmaType>, ) -> Self

Source

pub fn text_with_type(s: String, _lemma_type: Arc<LemmaType>) -> Self

Source

pub fn date_with_type(dt: SemanticDateTime, _lemma_type: Arc<LemmaType>) -> Self

Source

pub fn time_with_type(t: SemanticTime, _lemma_type: Arc<LemmaType>) -> Self

Source

pub fn calendar( value: RationalInteger, _unit: SemanticCalendarUnit, _lemma_type: Arc<LemmaType>, ) -> Self

Source

pub fn calendar_from_decimal( value: Decimal, unit: SemanticCalendarUnit, lemma_type: Arc<LemmaType>, ) -> Self

Source

pub fn calendar_with_type( value: RationalInteger, unit: SemanticCalendarUnit, lemma_type: Arc<LemmaType>, ) -> Self

Source

pub fn number_interpreted_as_measure( value: RationalInteger, _unit_name: String, ) -> Self

Source

pub fn from_bool(b: bool) -> Self

Source

pub fn from_datetime(dt: &DateTimeValue) -> Self

Source

pub fn date(dt: SemanticDateTime) -> Self

Source

pub fn time(t: SemanticTime) -> Self

Source

pub fn ratio(r: RationalInteger) -> Self

Source

pub fn ratio_from_decimal(r: Decimal) -> Self

Source

pub fn range(left: LiteralValue, right: LiteralValue) -> Self

Source

pub fn display_value(&self) -> String

Display without an explicit type. Measure/ratio fall back to magnitude-only.

Source

pub fn display_value_with_type(&self, lemma_type: &LemmaType) -> String

Display string given an explicit type (measure/ratio need unit identity).

Source

pub fn byte_size(&self) -> usize

Structural byte-size estimate for resource limit checks.

Source

pub fn magnitude_suggestion_for_decimal_prompt( &self, lemma_type: &LemmaType, ) -> Option<String>

Magnitude string for decimal input prompts.

Source

pub fn measure_units( &self, lemma_type: &LemmaType, ) -> Option<BTreeMap<String, String>>

Per-unit magnitudes when this literal is a measure with declared units.

Source

pub fn ratio_units( &self, lemma_type: &LemmaType, ) -> Option<BTreeMap<String, String>>

Per-unit magnitudes when this literal is a ratio with declared units.

Source

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.

Source

pub fn duration_canonical_seconds( &self, lemma_type: &LemmaType, ) -> RationalInteger

Derive second from a duration measure’s canonical magnitude.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for LiteralValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LiteralValue

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 LiteralValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LiteralValue

Source§

impl From<&LiteralValue> for LiteralValue

Source§

fn from(literal: &DomainLiteralValue) -> Self

Converts to this type from the input type.
Source§

impl Hash for LiteralValue

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 LiteralValue

Source§

fn eq(&self, other: &LiteralValue) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for LiteralValue

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 StructuralPartialEq for LiteralValue

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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, 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.