pub enum Value {
None,
Quantity(Quantity),
Bool(bool),
Integer(Integer),
String(String),
Array(Array),
Tuple(Box<Tuple>),
Matrix(Box<Matrix>),
Model(Model),
Return(Box<Value>),
}
Expand description
A variant value with attached source code reference.
Variants§
None
Invalid value (used for error handling).
Quantity(Quantity)
A quantity value.
Bool(bool)
A boolean value.
Integer(Integer)
An integer value.
String(String)
A string value.
Array(Array)
A list of values with a common type.
Tuple(Box<Tuple>)
A tuple of named items.
Matrix(Box<Matrix>)
A matrix.
Model(Model)
A model in the model tree.
Return(Box<Value>)
Return value
Implementations§
Source§impl Value
impl Value
Sourcepub fn is_invalid(&self) -> bool
pub fn is_invalid(&self) -> bool
Check if the value is invalid.
Sourcepub fn pow(&self, rhs: &Value) -> Result<Value, ValueError>
pub fn pow(&self, rhs: &Value) -> Result<Value, ValueError>
Calculate the power of two values, if possible.
Sourcepub fn binary_op(lhs: Value, rhs: Value, op: &str) -> Result<Value, ValueError>
pub fn binary_op(lhs: Value, rhs: Value, op: &str) -> Result<Value, ValueError>
Binary operation
Sourcepub fn try_bool(&self) -> Result<bool, ValueError>
pub fn try_bool(&self) -> Result<bool, ValueError>
Try to get boolean value.
A Value::None
will return false.
Sourcepub fn try_string(&self) -> Result<String, ValueError>
pub fn try_string(&self) -> Result<String, ValueError>
Try to convert to String
.
Sourcepub fn try_scalar(&self) -> Result<Scalar, ValueError>
pub fn try_scalar(&self) -> Result<Scalar, ValueError>
Try to convert to Scalar
.
Trait Implementations§
Source§impl AttributesAccess for Value
impl AttributesAccess for Value
Source§fn get_attributes_by_id(&self, id: &Identifier) -> Vec<Attribute>
fn get_attributes_by_id(&self, id: &Identifier) -> Vec<Attribute>
Get a value attribute by id.
Source§fn get_single_attribute(&self, id: &Identifier) -> Option<Attribute>
fn get_single_attribute(&self, id: &Identifier) -> Option<Attribute>
Get a single attributes.
Source§fn get_attribute_value(&self, id: &Identifier) -> Value
fn get_attribute_value(&self, id: &Identifier) -> Value
Get single attribute as value.
Source§fn get_resolution(&self) -> Option<ResolutionAttribute>
fn get_resolution(&self) -> Option<ResolutionAttribute>
Get resolution attribute.
Source§fn get_exports(&self) -> Vec<ExportCommand>
fn get_exports(&self) -> Vec<ExportCommand>
Get all export commands.
Source§fn get_measures(&self) -> Vec<MeasureCommand>
fn get_measures(&self) -> Vec<MeasureCommand>
Get all measure commands.
Source§fn get_custom_attributes(&self, id: &Identifier) -> Vec<Tuple>
fn get_custom_attributes(&self, id: &Identifier) -> Vec<Tuple>
Get custom attributes.
Source§impl CallMethod for Value
impl CallMethod for Value
Source§fn call_method(
&self,
id: &QualifiedName,
args: &ArgumentValueList,
context: &mut Context,
) -> EvalResult<Value>
fn call_method( &self, id: &QualifiedName, args: &ArgumentValueList, context: &mut Context, ) -> EvalResult<Value>
Evaluate method call into a value (if possible) Read more
Source§impl From<Attribute> for Value
This trait implementation is used to access values from an attribute.
impl From<Attribute> for Value
This trait implementation is used to access values from an attribute.
Source§impl From<BuiltinValueHelper> for Value
impl From<BuiltinValueHelper> for Value
Source§fn from(value: BuiltinValueHelper) -> Self
fn from(value: BuiltinValueHelper) -> Self
Converts to this type from the input type.
Source§impl From<ExportCommand> for Value
impl From<ExportCommand> for Value
Source§fn from(export_attribute: ExportCommand) -> Self
fn from(export_attribute: ExportCommand) -> Self
Converts to this type from the input type.
Source§impl From<MeasureCommand> for Value
impl From<MeasureCommand> for Value
Source§fn from(command: MeasureCommand) -> Self
fn from(command: MeasureCommand) -> Self
Converts to this type from the input type.
Source§impl From<NumberLiteral> for Value
impl From<NumberLiteral> for Value
Source§fn from(literal: NumberLiteral) -> Self
fn from(literal: NumberLiteral) -> Self
Converts to this type from the input type.
Source§impl From<ResolutionAttribute> for Value
impl From<ResolutionAttribute> for Value
Source§fn from(resolution_attribute: ResolutionAttribute) -> Self
fn from(resolution_attribute: ResolutionAttribute) -> Self
Converts to this type from the input type.
Source§impl FromIterator<Value> for Array
impl FromIterator<Value> for Array
Source§impl FromIterator<Value> for Value
impl FromIterator<Value> for Value
Source§impl FromIterator<Value> for ValueList
impl FromIterator<Value> for ValueList
Source§impl Mul<Unit> for Value
Multiply a Unit with a value. Used for unit bundling: [1,2,3]mm
.
impl Mul<Unit> for Value
Multiply a Unit with a value. Used for unit bundling: [1,2,3]mm
.
[1,2,3]mm
is a shortcut for [1,2,3] * 1mm
.
Source§impl Mul<Value> for Array
- operator. Multiply a value from an array, e.g.:
[1,2] * 2 == [2,4]
.
impl Mul<Value> for Array
- operator. Multiply a value from an array, e.g.:
[1,2] * 2 == [2,4]
.
Source§impl PartialOrd for Value
impl PartialOrd for Value
Source§impl Sub<Value> for Array
- operator. Subtracts a value from an array, e.g.:
[1,2] - 1 == [0,1]
.
impl Sub<Value> for Array
- operator. Subtracts a value from an array, e.g.:
[1,2] - 1 == [0,1]
.
Source§impl TreeDisplay for Value
impl TreeDisplay for Value
Source§impl TryFrom<Value> for ResolutionAttribute
impl TryFrom<Value> for ResolutionAttribute
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl !UnwindSafe for Value
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,
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>
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 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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string()
Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString
. Read more