Skip to main content

Expression

Enum Expression 

Source
pub enum Expression {
Show 16 variants Null(Decorated<Null>), Bool(Decorated<bool>), Number(Formatted<Number>), String(Decorated<String>), Array(Array), Object(Object), StringTemplate(StringTemplate), HeredocTemplate(Box<HeredocTemplate>), Parenthesis(Box<Parenthesis>), Variable(Decorated<Ident>), Conditional(Box<Conditional>), FuncCall(Box<FuncCall>), Traversal(Box<Traversal>), UnaryOp(Box<UnaryOp>), BinaryOp(Box<BinaryOp>), ForExpr(Box<ForExpr>),
}
Expand description

A type representing any expression from the expression sub-language.

Variants§

§

Null(Decorated<Null>)

Represents a null value.

§

Bool(Decorated<bool>)

Represents a boolean.

§

Number(Formatted<Number>)

Represents a number, either integer or float.

§

String(Decorated<String>)

Represents a string that does not contain any template interpolations or template directives.

§

Array(Array)

Represents an HCL array.

§

Object(Object)

Represents an HCL object.

§

StringTemplate(StringTemplate)

Represents a string containing template interpolations and template directives.

§

HeredocTemplate(Box<HeredocTemplate>)

Represents an HCL heredoc template.

§

Parenthesis(Box<Parenthesis>)

Represents a sub-expression wrapped in parenthesis.

§

Variable(Decorated<Ident>)

Represents a variable identifier.

§

Conditional(Box<Conditional>)

Represents conditional operator which selects one of two rexpressions based on the outcome of a boolean expression.

§

FuncCall(Box<FuncCall>)

Represents a function call.

§

Traversal(Box<Traversal>)

Represents an attribute or element traversal.

§

UnaryOp(Box<UnaryOp>)

Represents an operation which applies a unary operator to an expression.

§

BinaryOp(Box<BinaryOp>)

Represents an operation which applies a binary operator to two expressions.

§

ForExpr(Box<ForExpr>)

Represents a construct for constructing a collection by projecting the items from another collection.

Implementations§

Source§

impl Expression

Source

pub fn null() -> Expression

Creates a null expression.

Source

pub fn is_null(&self) -> bool

Returns true if the expression represents null.

Source

pub fn is_bool(&self) -> bool

Returns true if the expression is a bool.

Source

pub fn as_bool(&self) -> Option<bool>

If the expression is a bool, returns a reference to it, otherwise None.

Source

pub fn is_number(&self) -> bool

Returns true if the expression is a number.

Source

pub fn as_number(&self) -> Option<&Number>

If the expression is a number, returns a reference to it, otherwise None.

Source

pub fn is_str(&self) -> bool

Returns true if the expression is a string.

Source

pub fn as_str(&self) -> Option<&str>

If the expression is a string, returns a reference to it, otherwise None.

Source

pub fn is_array(&self) -> bool

Returns true if the expression is an array.

Source

pub fn as_array(&self) -> Option<&Array>

If the expression is an array, returns a reference to it, otherwise None.

Source

pub fn as_array_mut(&mut self) -> Option<&mut Array>

If the expression is an array, returns a mutable reference to it, otherwise None.

Source

pub fn is_object(&self) -> bool

Returns true if the expression is an object.

Source

pub fn as_object(&self) -> Option<&Object>

If the expression is an object, returns a reference to it, otherwise None.

Source

pub fn as_object_mut(&mut self) -> Option<&mut Object>

If the expression is an object, returns a mutable reference to it, otherwise None.

Source

pub fn is_template(&self) -> bool

Returns true if the expression is either of variant StringTemplate or HeredocTemplate.

Source

pub fn as_template(&self) -> Option<&Template>

If the expression is either of variant StringTemplate or HeredocTemplate, returns a reference to the underlying Template, otherwise None.

Source

pub fn is_string_template(&self) -> bool

Returns true if the expression is a string template.

Source

pub fn as_string_template(&self) -> Option<&StringTemplate>

If the expression is a string template, returns a reference to it, otherwise None.

Source

pub fn is_heredoc_template(&self) -> bool

Returns true if the expression is a heredoc template.

Source

pub fn as_heredoc_template(&self) -> Option<&HeredocTemplate>

If the expression is a heredoc template, returns a reference to it, otherwise None.

Source

pub fn is_parenthesis(&self) -> bool

Returns true if the expression is wrapped in parenthesis.

Source

pub fn as_parenthesis(&self) -> Option<&Parenthesis>

If the expression is an expression wrapped in parenthesis, returns a reference to it, otherwise None.

Source

pub fn is_variable(&self) -> bool

Returns true if the expression is a variable.

Source

pub fn as_variable(&self) -> Option<&Ident>

If the expression is a variable, returns a reference to it, otherwise None.

Source

pub fn is_conditional(&self) -> bool

Returns true if the expression is a conditional.

Source

pub fn as_conditional(&self) -> Option<&Conditional>

If the expression is a conditional, returns a reference to it, otherwise None.

Source

pub fn is_func_call(&self) -> bool

Returns true if the expression is a function call.

Source

pub fn as_func_call(&self) -> Option<&FuncCall>

If the expression is a function call, returns a reference to it, otherwise None.

Source

pub fn is_traversal(&self) -> bool

Returns true if the expression is a traversal.

Source

pub fn as_traversal(&self) -> Option<&Traversal>

If the expression is a traversal, returns a reference to it, otherwise None.

Source

pub fn is_unary_op(&self) -> bool

Returns true if the expression is a unary op.

Source

pub fn as_unary_op(&self) -> Option<&UnaryOp>

If the expression is a unary op, returns a reference to it, otherwise None.

Source

pub fn is_binary_op(&self) -> bool

Returns true if the expression is a binary op.

Source

pub fn as_binary_op(&self) -> Option<&BinaryOp>

If the expression is a binary op, returns a reference to it, otherwise None.

Source

pub fn is_for_expr(&self) -> bool

Returns true if the expression is a for expression.

Source

pub fn as_for_expr(&self) -> Option<&ForExpr>

If the expression is a for expression, returns a reference to it, otherwise None.

Trait Implementations§

Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

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 Expression

Source§

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

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

impl Decorate for Expression

Source§

fn decor(&self) -> &Decor

Returns a reference to the object’s Decor.
Source§

fn decor_mut(&mut self) -> &mut Decor

Returns a mutable reference to the object’s Decor.
Source§

fn decorate(&mut self, decor: impl Into<Decor>)

Decorate the object with decor in-place.
Source§

fn decorated(self, decor: impl Into<Decor>) -> Self
where Self: Sized,

Decorate the object with decor and return the modified value.
Source§

impl Display for Expression

Source§

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

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

impl Eq for Expression

Source§

impl<'a, T> From<&'a [T]> for Expression
where T: Clone + Into<Expression>,

Source§

fn from(value: &'a [T]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Expression

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Array> for Expression

Source§

fn from(value: Array) -> Self

Converts to this type from the input type.
Source§

impl From<BinaryOp> for Expression

Source§

fn from(value: BinaryOp) -> Self

Converts to this type from the input type.
Source§

impl From<Conditional> for Expression

Source§

fn from(value: Conditional) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Cow<'a, str>> for Expression

Source§

fn from(s: Cow<'a, str>) -> Self

Converts to this type from the input type.
Source§

impl From<Decorated<Ident>> for Expression

Source§

fn from(value: Decorated<Ident>) -> Self

Converts to this type from the input type.
Source§

impl From<Decorated<String>> for Expression

Source§

fn from(value: Decorated<String>) -> Self

Converts to this type from the input type.
Source§

impl From<Decorated<bool>> for Expression

Source§

fn from(value: Decorated<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Expression> for ForCond

Source§

fn from(value: Expression) -> Self

Converts to this type from the input type.
Source§

impl From<Expression> for ObjectKey

Source§

fn from(expr: Expression) -> Self

Converts to this type from the input type.
Source§

impl From<Expression> for ObjectValue

Source§

fn from(expr: Expression) -> Self

Converts to this type from the input type.
Source§

impl From<ForExpr> for Expression

Source§

fn from(value: ForExpr) -> Self

Converts to this type from the input type.
Source§

impl From<Formatted<Number>> for Expression

Source§

fn from(value: Formatted<Number>) -> Self

Converts to this type from the input type.
Source§

impl From<FuncCall> for Expression

Source§

fn from(value: FuncCall) -> Self

Converts to this type from the input type.
Source§

impl From<HeredocTemplate> for Expression

Source§

fn from(value: HeredocTemplate) -> Self

Converts to this type from the input type.
Source§

impl From<Ident> for Expression

Source§

fn from(value: Ident) -> Self

Converts to this type from the input type.
Source§

impl From<Number> for Expression

Source§

fn from(value: Number) -> Self

Converts to this type from the input type.
Source§

impl From<Object> for Expression

Source§

fn from(value: Object) -> Self

Converts to this type from the input type.
Source§

impl From<Parenthesis> for Expression

Source§

fn from(value: Parenthesis) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Expression

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<StringTemplate> for Expression

Source§

fn from(value: StringTemplate) -> Self

Converts to this type from the input type.
Source§

impl From<Traversal> for Expression

Source§

fn from(value: Traversal) -> Self

Converts to this type from the input type.
Source§

impl From<UnaryOp> for Expression

Source§

fn from(value: UnaryOp) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for Expression
where T: Into<Expression>,

Source§

fn from(value: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Expression

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Expression

Source§

fn from(f: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Expression

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Expression

Source§

fn from(n: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Expression

Source§

fn from(n: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Expression

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Expression

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for Expression

Source§

fn from(n: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Expression

Source§

fn from(n: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Expression

Source§

fn from(n: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Expression

Source§

fn from(n: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Expression

Source§

fn from(n: u64) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Expression

Source§

fn from(n: usize) -> Self

Converts to this type from the input type.
Source§

impl<K: Into<ObjectKey>, V: Into<ObjectValue>> FromIterator<(K, V)> for Expression

Source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Into<Expression>> FromIterator<T> for Expression

Source§

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

Creates a value from an iterator. Read more
Source§

impl FromStr for Expression

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Expression

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Span for Expression

Source§

fn span(&self) -> Option<Range<usize>>

Obtains the span information. This only returns Some if the value was emitted by the parser. Read more
Source§

impl StructuralPartialEq for Expression

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