Enum hcl::Expression

source ·
#[non_exhaustive]
pub enum Expression {
Show 14 variants Null, Bool(bool), Number(Number), String(String), Array(Vec<Expression>), Object(Object<ObjectKey, Expression>), TemplateExpr(Box<TemplateExpr>), Variable(Variable), Traversal(Box<Traversal>), FuncCall(Box<FuncCall>), Parenthesis(Box<Expression>), Conditional(Box<Conditional>), Operation(Box<Operation>), ForExpr(Box<ForExpr>),
}
Expand description

A type representing the expression sub-language. It is used in HCL attributes to specify values and in HCL templates.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Null

Represents a null value.

§

Bool(bool)

Represents a boolean.

§

Number(Number)

Represents a number, either integer or float.

§

String(String)

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

§

Array(Vec<Expression>)

Represents array.

§

Object(Object<ObjectKey, Expression>)

Represents an object.

§

TemplateExpr(Box<TemplateExpr>)

A quoted string or heredoc that embeds a program written in the template sub-language.

§

Variable(Variable)

Represents a variable name identifier.

§

Traversal(Box<Traversal>)

Represents an attribute or element traversal.

§

FuncCall(Box<FuncCall>)

Represents a function call.

§

Parenthesis(Box<Expression>)

Represents a sub-expression that is wrapped in parenthesis.

§

Conditional(Box<Conditional>)

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

§

Operation(Box<Operation>)

An operation which applies a particular operator to either one or two expression terms.

§

ForExpr(Box<ForExpr>)

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

Trait Implementations§

source§

impl Clone for Expression

source§

fn clone(&self) -> Expression

Returns a copy 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 Expression

source§

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

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

impl<'de> Deserialize<'de> for Expression

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserializer<'de> for Expression

§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
source§

fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
source§

fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
source§

fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
source§

fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
source§

fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
source§

fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
source§

fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
source§

fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
source§

fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
source§

fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
source§

fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
source§

fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
source§

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
source§

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
source§

fn deserialize_enum<V>( self, name: &'static str, _variants: &'static [&'static str], visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
source§

fn deserialize_newtype_struct<V>( self, _name: &'static str, visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
source§

fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
source§

fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
source§

fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
source§

fn deserialize_unit_struct<V>( self, _name: &'static str, visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
source§

fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
source§

fn deserialize_tuple<V>( self, _len: usize, visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
source§

fn deserialize_tuple_struct<V>( self, _name: &'static str, _len: usize, visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
source§

fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
source§

fn deserialize_struct<V>( self, _name: &'static str, _fields: &'static [&'static str], visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
source§

fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
source§

fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
source§

impl Display for Expression

source§

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

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

impl<'de> EnumAccess<'de> for Expression

§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
§

type Variant = Expression

The Visitor that will be used to deserialize the content of the enum variant.
source§

fn variant_seed<T>( self, seed: T ) -> Result<(T::Value, Self::Variant), Self::Error>
where T: DeserializeSeed<'de>,

variant is called to identify which variant to deserialize. Read more
source§

fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
where V: Deserialize<'de>,

variant is called to identify which variant to deserialize. Read more
source§

impl Evaluate for Expression

§

type Output = Value

The type that is returned by evaluate on success.
source§

fn evaluate(&self, ctx: &Context<'_>) -> EvalResult<Self::Output>

Recursively evaluates all HCL templates and expressions in the implementing type using the variables and functions declared in the Context. Read more
source§

fn evaluate_in_place(&mut self, ctx: &Context<'_>) -> EvalResult<(), Errors>

Recursively tries to evaluate all nested expressions in place. Read more
source§

impl Format for Expression

source§

fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>
where W: Write,

Formats a HCL structure using a formatter and writes the result to the provided writer. Read more
source§

fn format_vec<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<Vec<u8>>
where W: Write + AsMut<Vec<u8>>,

Formats a HCL structure using a formatter and returns the result as a Vec<u8>. Read more
source§

fn format_string<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<String>
where W: Write + AsMut<Vec<u8>>,

Formats a HCL structure using a formatter and returns the result as a String. Read more
source§

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

source§

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

Converts to this type from the input type.
source§

impl From<&str> for Expression

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

impl From<()> for Expression

source§

fn from((): ()) -> Self

Converts to this type from the input type.
source§

impl From<BinaryOp> for Expression

source§

fn from(op: BinaryOp) -> Self

Converts to this type from the input type.
source§

impl From<Conditional> for Expression

source§

fn from(cond: 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<Expression> for Expression

source§

fn from(value: Expression) -> Self

Converts to this type from the input type.
source§

impl From<Expression> for Expression

source§

fn from(value: Expression) -> Self

Converts to this type from the input type.
source§

impl From<Expression> for ObjectValue

source§

fn from(value: Expression) -> Self

Converts to this type from the input type.
source§

impl From<Expression> for TraversalOperator

source§

fn from(value: Expression) -> TraversalOperator

Converts to this type from the input type.
source§

impl From<Expression> for Value

source§

fn from(expr: Expression) -> Self

Converts to this type from the input type.
source§

impl From<ForExpr> for Expression

source§

fn from(expr: ForExpr) -> Self

Converts to this type from the input type.
source§

impl From<FuncCall> for Expression

source§

fn from(func_call: FuncCall) -> Self

Converts to this type from the input type.
source§

impl From<Heredoc> for Expression

source§

fn from(heredoc: Heredoc) -> Self

Converts to this type from the input type.
source§

impl From<Number> for Expression

source§

fn from(num: Number) -> Self

Converts to this type from the input type.
source§

impl From<ObjectValue> for Expression

source§

fn from(value: ObjectValue) -> Self

Converts to this type from the input type.
source§

impl From<Operation> for Expression

source§

fn from(op: Operation) -> Self

Converts to this type from the input type.
source§

impl From<String> for Expression

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl<T> From<T> for Expression
where T: IntoJsonSpec,

source§

fn from(value: T) -> Expression

Converts to this type from the input type.
source§

impl From<TemplateExpr> for Expression

source§

fn from(expr: TemplateExpr) -> Self

Converts to this type from the input type.
source§

impl From<Traversal> for Expression

source§

fn from(traversal: Traversal) -> Self

Converts to this type from the input type.
source§

impl From<UnaryOp> for Expression

source§

fn from(op: UnaryOp) -> Self

Converts to this type from the input type.
source§

impl From<Value> for Expression

source§

fn from(value: Value) -> Self

Converts to this type from the input type.
source§

impl From<Variable> for Expression

source§

fn from(variable: Variable) -> Self

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl From<VecMap<ObjectKey, Expression>> for Expression

source§

fn from(f: Object<ObjectKey, Expression>) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Expression

source§

fn from(b: 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<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<i8> for Expression

source§

fn from(n: i8) -> 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<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<u8> for Expression

source§

fn from(n: u8) -> 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<Expression>> 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<'de> IntoDeserializer<'de, Error> for Expression

§

type Deserializer = Expression

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> Self::Deserializer

Convert this value into a deserializer.
source§

impl PartialEq for Expression

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Expression

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'de> VariantAccess<'de> for Expression

§

type Error = Error

The error type that can be returned if some error occurs during deserialization. Must match the error type of our EnumAccess.
source§

fn unit_variant(self) -> Result<(), Self::Error>

Called when deserializing a variant with no values. Read more
source§

fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
where T: DeserializeSeed<'de>,

Called when deserializing a variant with a single value. Read more
source§

fn tuple_variant<V>( self, _len: usize, visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a tuple-like variant. Read more
source§

fn struct_variant<V>( self, _fields: &'static [&'static str], visitor: V ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a struct-like variant. Read more
source§

fn newtype_variant<T>(self) -> Result<T, Self::Error>
where T: Deserialize<'de>,

Called when deserializing a variant with a single value. Read more
source§

impl Eq for Expression

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

§

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§

default 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>,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,