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
impl Expression
Sourcepub fn null() -> Expression
pub fn null() -> Expression
Creates a null
expression.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
If the expression is a bool, returns a reference to it, otherwise None
.
Sourcepub fn as_number(&self) -> Option<&Number>
pub fn as_number(&self) -> Option<&Number>
If the expression is a number, returns a reference to it, otherwise None
.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
If the expression is a string, returns a reference to it, otherwise None
.
Sourcepub fn as_array(&self) -> Option<&Array>
pub fn as_array(&self) -> Option<&Array>
If the expression is an array, returns a reference to it, otherwise None
.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Array>
pub fn as_array_mut(&mut self) -> Option<&mut Array>
If the expression is an array, returns a mutable reference to it, otherwise None
.
Sourcepub fn as_object(&self) -> Option<&Object>
pub fn as_object(&self) -> Option<&Object>
If the expression is an object, returns a reference to it, otherwise None
.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut Object>
pub fn as_object_mut(&mut self) -> Option<&mut Object>
If the expression is an object, returns a mutable reference to it, otherwise None
.
Sourcepub fn is_template(&self) -> bool
pub fn is_template(&self) -> bool
Returns true
if the expression is either of variant StringTemplate
or
HeredocTemplate
.
Sourcepub fn as_template(&self) -> Option<&Template>
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
.
Sourcepub fn is_string_template(&self) -> bool
pub fn is_string_template(&self) -> bool
Returns true
if the expression is a string template.
Sourcepub fn as_string_template(&self) -> Option<&StringTemplate>
pub fn as_string_template(&self) -> Option<&StringTemplate>
If the expression is a string template, returns a reference to it, otherwise None
.
Sourcepub fn is_heredoc_template(&self) -> bool
pub fn is_heredoc_template(&self) -> bool
Returns true
if the expression is a heredoc template.
Sourcepub fn as_heredoc_template(&self) -> Option<&HeredocTemplate>
pub fn as_heredoc_template(&self) -> Option<&HeredocTemplate>
If the expression is a heredoc template, returns a reference to it, otherwise None
.
Sourcepub fn is_parenthesis(&self) -> bool
pub fn is_parenthesis(&self) -> bool
Returns true
if the expression is wrapped in parenthesis.
Sourcepub fn as_parenthesis(&self) -> Option<&Parenthesis>
pub fn as_parenthesis(&self) -> Option<&Parenthesis>
If the expression is an expression wrapped in parenthesis, returns a reference to it,
otherwise None
.
Sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
Returns true
if the expression is a variable.
Sourcepub fn as_variable(&self) -> Option<&Ident>
pub fn as_variable(&self) -> Option<&Ident>
If the expression is a variable, returns a reference to it, otherwise None
.
Sourcepub fn is_conditional(&self) -> bool
pub fn is_conditional(&self) -> bool
Returns true
if the expression is a conditional.
Sourcepub fn as_conditional(&self) -> Option<&Conditional>
pub fn as_conditional(&self) -> Option<&Conditional>
If the expression is a conditional, returns a reference to it, otherwise None
.
Sourcepub fn is_func_call(&self) -> bool
pub fn is_func_call(&self) -> bool
Returns true
if the expression is a function call.
Sourcepub fn as_func_call(&self) -> Option<&FuncCall>
pub fn as_func_call(&self) -> Option<&FuncCall>
If the expression is a function call, returns a reference to it, otherwise None
.
Sourcepub fn is_traversal(&self) -> bool
pub fn is_traversal(&self) -> bool
Returns true
if the expression is a traversal.
Sourcepub fn as_traversal(&self) -> Option<&Traversal>
pub fn as_traversal(&self) -> Option<&Traversal>
If the expression is a traversal, returns a reference to it, otherwise None
.
Sourcepub fn is_unary_op(&self) -> bool
pub fn is_unary_op(&self) -> bool
Returns true
if the expression is a unary op.
Sourcepub fn as_unary_op(&self) -> Option<&UnaryOp>
pub fn as_unary_op(&self) -> Option<&UnaryOp>
If the expression is a unary op, returns a reference to it, otherwise None
.
Sourcepub fn is_binary_op(&self) -> bool
pub fn is_binary_op(&self) -> bool
Returns true
if the expression is a binary op.
Sourcepub fn as_binary_op(&self) -> Option<&BinaryOp>
pub fn as_binary_op(&self) -> Option<&BinaryOp>
If the expression is a binary op, returns a reference to it, otherwise None
.
Sourcepub fn is_for_expr(&self) -> bool
pub fn is_for_expr(&self) -> bool
Returns true
if the expression is a for
expression.
Sourcepub fn as_for_expr(&self) -> Option<&ForExpr>
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
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more