Value

Enum Value 

Source
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

Source

pub fn is_invalid(&self) -> bool

Check if the value is invalid.

Source

pub fn pow(&self, rhs: &Value) -> Result<Value, ValueError>

Calculate the power of two values, if possible.

Source

pub fn binary_op(lhs: Value, rhs: Value, op: &str) -> Result<Value, ValueError>

Binary operation

Source

pub fn unary_op(self, op: &str) -> Result<Value, ValueError>

Unary operation.

Source

pub fn try_bool(&self) -> Result<bool, ValueError>

Try to get boolean value.

A Value::None will return false.

Source

pub fn try_string(&self) -> Result<String, ValueError>

Try to convert to String.

Source

pub fn try_scalar(&self) -> Result<Scalar, ValueError>

Try to convert to Scalar.

Trait Implementations§

Source§

impl Add<Value> for Array

  • operator. Adds a value to an array, e.g.: [1,2] + 1 == [2,3].
Source§

type Output = Result<Value, ValueError>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Value) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Value

Rules for operator +.

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AttributesAccess for Value

Source§

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>

Get a single attributes.
Source§

fn get_attribute_value(&self, id: &Identifier) -> Value

Get single attribute as value.
Source§

fn get_resolution(&self) -> Option<ResolutionAttribute>

Get resolution attribute.
Source§

fn get_color(&self) -> Option<Color>

Color (builtin attribute).
Source§

fn get_theme(&self) -> Option<Rc<Theme>>

Color theme (builtin attribute).
Source§

fn get_size(&self) -> Option<Size2>

Get size.
Source§

fn get_exports(&self) -> Vec<ExportCommand>

Get all export commands.
Source§

fn get_measures(&self) -> Vec<MeasureCommand>

Get all measure commands.
Source§

fn get_custom_attributes(&self, id: &Identifier) -> Vec<Tuple>

Get custom attributes.
Source§

impl BitAnd for Value

Rules for operator & (intersection).

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitOr for Value

Rules for operator `|`` (union).

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl CallMethod for Value

Source§

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 Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl Default for Value

Source§

fn default() -> Value

Returns the “default value” for a type. Read more
Source§

impl Display for Value

Source§

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

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

impl Div<Value> for Array

/ operator. Divide an array by value, e.g.: [2,4] / 2 == [1,2].

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Value) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Value> for Tuple

Source§

type Output = Result<Tuple, ValueError>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Value) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Value

Rules for operator /.

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl From<Attribute> for Value

This trait implementation is used to access values from an attribute.

Source§

fn from(value: Attribute) -> Self

Converts to this type from the input type.
Source§

impl From<BuiltinValueHelper> for Value

Source§

fn from(value: BuiltinValueHelper) -> Self

Converts to this type from the input type.
Source§

impl From<ExportCommand> for Value

Source§

fn from(export_attribute: ExportCommand) -> Self

Converts to this type from the input type.
Source§

impl From<Literal> for Value

Source§

fn from(literal: Literal) -> Self

Converts to this type from the input type.
Source§

impl From<MeasureCommand> for Value

Source§

fn from(command: MeasureCommand) -> Self

Converts to this type from the input type.
Source§

impl From<Model> for Value

Source§

fn from(model: Model) -> Self

Converts to this type from the input type.
Source§

impl From<NumberLiteral> for Value

Source§

fn from(literal: NumberLiteral) -> Self

Converts to this type from the input type.
Source§

impl From<Quantity> for Value

Source§

fn from(qty: Quantity) -> Self

Converts to this type from the input type.
Source§

impl From<Rc<Theme>> for Value

Source§

fn from(theme: Rc<Theme>) -> Self

Converts to this type from the input type.
Source§

impl From<ResolutionAttribute> for Value

Source§

fn from(resolution_attribute: ResolutionAttribute) -> Self

Converts to this type from the input type.
Source§

impl From<Size2> for Value

Source§

fn from(value: Size2) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<Tuple> for Value

Source§

fn from(tuple: Tuple) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(f: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(scalar: Scalar) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Value> for Array

Source§

fn from_iter<T: IntoIterator<Item = Value>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<Value> for Value

Source§

fn from_iter<T: IntoIterator<Item = Value>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<Value> for ValueList

Source§

fn from_iter<T: IntoIterator<Item = Value>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

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§

type Output = Result<Value, ValueError>

The resulting type after applying the * operator.
Source§

fn mul(self, unit: Unit) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Value> for Array

  • operator. Multiply a value from an array, e.g.: [1,2] * 2 == [2,4].
Source§

type Output = Result<Value, ValueError>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Value) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Value> for Tuple

Source§

type Output = Result<Tuple, ValueError>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Value) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Value

Rules for operator *.

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for Value

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Value

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Value> for Array

  • operator. Subtracts a value from an array, e.g.: [1,2] - 1 == [0,1].
Source§

type Output = Result<Value, ValueError>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Value) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Value

Rules for operator -.

Source§

type Output = Result<Value, ValueError>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl TreeDisplay for Value

Source§

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

Write item into f and use {:depth$} syntax in front of your single line output to get proper indention.
Source§

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

Display as tree starting at depth 0.
Source§

fn write_tree(&self, f: &mut impl Write) -> Result<()>

Display as tree starting at depth 0.
Source§

impl<'a> TryFrom<&'a Value> for &'a Tuple

Source§

type Error = ValueError

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

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for Mat3

Source§

type Error = ValueError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for Size2

Source§

type Error = ValueError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for String

Source§

type Error = ValueError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for bool

Source§

type Error = ValueError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for Scalar

Source§

type Error = ValueError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for i64

Source§

type Error = ValueError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Color> for Value

Source§

type Error = ValueError

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

fn try_from(c: Color) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for ResolutionAttribute

Source§

type Error = ValueError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for String

Source§

type Error = ValueError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for bool

Source§

type Error = ValueError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Scalar

Source§

type Error = ValueError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i64

Source§

type Error = ValueError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Ty for Value

Source§

fn ty(&self) -> Type

Return type
Source§

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> 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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool