#[non_exhaustive]pub enum Value<'a> {
Str(&'a str),
Int(i64),
Float(f64),
Decimal(&'a str),
Number(Number),
Custom(&'a dyn CustomValue),
Boxed(Box<dyn Any>),
Fallback(FallbackSource<'a>),
DateTime(DateTime<'a>),
Measure(Measure<'a>),
}Expand description
A resolved value’s data. The handler that resolved it decides how it
formats and selects; a value no handler resolved (a literal, an
argument) is unannotated (plans/03-runtime.md §2.6).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Str(&'a str)
A string: a literal, a string argument, or :string’s operand.
Int(i64)
An integer argument.
Float(f64)
A float argument.
Decimal(&'a str)
A decimal argument (number-literal text).
Number(Number)
A number and its resolved options: :number, :integer, :offset,
:percent.
Custom(&'a dyn CustomValue)
An application value.
Boxed(Box<dyn Any>)
A custom handler’s own data (the only allocation a handler makes).
Fallback(FallbackSource<'a>)
A fallback value, as a function’s operand: the operand failed to
resolve (an unresolved variable, a declaration that failed). The
handler decides — the numeric ones report Bad Operand, :string
takes the text of its representation ({$x}), as the suite expects
(plans/03-runtime.md §2.6).
DateTime(DateTime<'a>)
A date/time: an argument, or what :datetime, :date, :time
resolved (with its options).
Measure(Measure<'a>)
A number with a currency or a unit: what :currency and :unit
resolved.
Implementations§
Source§impl<'a> Value<'a>
impl<'a> Value<'a>
Sourcepub fn from_arg(arg: Arg<'a>) -> Option<Value<'a>>
pub fn from_arg(arg: Arg<'a>) -> Option<Value<'a>>
The value of an argument; None for Arg::Unset.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Its string form when it has one without formatting: a string, a
decimal’s text, or an application value’s as_str.
Sourcepub fn to_number(&self, host: &dyn Host) -> Option<Number>
pub fn to_number(&self, host: &dyn Host) -> Option<Number>
Its numeric value under the numeric-operand rules (number.md,
“Numeric Operands”): a string or decimal matching number-literal,
an integer, a finite float, a number or a measure (its value, without
options), an application value’s as_number (else its measure’s).
Sourcepub fn digit_size(&self) -> Option<u8>
pub fn digit_size(&self) -> Option<u8>
Its value as a digit size option (number.md): an integer 0–99 —
an integer, an integral float, a number, or a string of one or two
digits without a leading zero. For the function crates’ own options
of that type (fractionDigits).
Sourcepub fn downcast_ref<T: Any>(&self) -> Option<&T>
pub fn downcast_ref<T: Any>(&self) -> Option<&T>
The concrete value, when it is a T: a Value::Boxed, or an
application value whose as_any gives one.