Enum hcl::Value

source ·
pub enum Value {
    Null,
    Bool(bool),
    Number(Number),
    String(String),
    Array(Vec<Value>),
    Object(Map<String, Value>),
}
Expand description

Represents any valid HCL value.

Variants§

§

Null

Represents a HCL null value.

§

Bool(bool)

Represents a HCL boolean.

§

Number(Number)

Represents a HCL number, either integer or float.

§

String(String)

Represents a HCL string.

§

Array(Vec<Value>)

Represents a HCL array.

§

Object(Map<String, Value>)

Represents a HCL object.

Implementations§

source§

impl Value

source

pub fn as_array(&self) -> Option<&Vec<Value>>

If the Value is an Array, returns the associated vector. Returns None otherwise.

source

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

If the Value is an Array, returns the associated mutable vector. Returns None otherwise.

source

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

If the Value is a Boolean, represent it as bool if possible. Returns None otherwise.

source

pub fn as_f64(&self) -> Option<f64>

If the Value is a Number, represent it as f64 if possible. Returns None otherwise.

source

pub fn as_i64(&self) -> Option<i64>

If the Value is a Number, represent it as i64 if possible. Returns None otherwise.

source

pub fn as_null(&self) -> Option<()>

If the Value is a Null, returns (). Returns None otherwise.

source

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

If the Value is a Number, returns the associated Number. Returns None otherwise.

source

pub fn as_object(&self) -> Option<&Map<String, Value>>

If the Value is an Object, returns the associated Map. Returns None otherwise.

source

pub fn as_object_mut(&mut self) -> Option<&mut Map<String, Value>>

If the Value is an Object, returns the associated mutable Map. Returns None otherwise.

source

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

If the Value is a String, returns the associated str. Returns None otherwise.

source

pub fn as_u64(&self) -> Option<u64>

If the Value is a Number, represent it as u64 if possible. Returns None otherwise.

source

pub fn is_array(&self) -> bool

Returns true if the Value is an Array. Returns false otherwise.

For any Value on which is_array returns true, as_array and as_array_mut are guaranteed to return the vector representing the array.

source

pub fn is_boolean(&self) -> bool

Returns true if the Value is a Boolean. Returns false otherwise.

For any Value on which is_boolean returns true, as_bool is guaranteed to return the boolean value.

source

pub fn is_f64(&self) -> bool

Returns true if the Value is a number that can be represented by f64.

For any Value on which is_f64 returns true, as_f64 is guaranteed to return the floating point value.

source

pub fn is_i64(&self) -> bool

Returns true if the Value is an integer between i64::MIN and i64::MAX.

For any Value on which is_i64 returns true, as_i64 is guaranteed to return the integer value.

source

pub fn is_number(&self) -> bool

Returns true if the Value is a Number. Returns false otherwise.

source

pub fn is_null(&self) -> bool

Returns true if the Value is a Null. Returns false otherwise.

For any Value on which is_null returns true, as_null is guaranteed to return Some(()).

source

pub fn is_object(&self) -> bool

Returns true if the Value is an Object. Returns false otherwise.

For any Value on which is_object returns true, as_object and as_object_mut are guaranteed to return the map representation of the object.

source

pub fn is_string(&self) -> bool

Returns true if the Value is a String. Returns false otherwise.

For any Value on which is_string returns true, as_str is guaranteed to return the string slice.

source

pub fn is_u64(&self) -> bool

Returns true if the Value is an integer between zero and u64::MAX.

For any Value on which is_u64 returns true, as_u64 is guaranteed to return the integer value.

source

pub fn take(&mut self) -> Value

Takes the value out of the Value, leaving a Null in its place.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

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 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<'de> Deserialize<'de> for Value

source§

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

Deserialize this value from the given Serde deserializer. 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 Format for Value

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<Value>> From<&'a [T]> for Value

source§

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

Converts to this type from the input type.
source§

impl From<&str> for Value

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

impl From<()> for Value

source§

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

Converts to this type from the input type.
source§

impl From<Attribute> for Value

source§

fn from(attr: Attribute) -> Value

Converts to this type from the input type.
source§

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

source§

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

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<IndexMap<String, Value>> for Value

source§

fn from(f: Map<String, Value>) -> Self

Converts to this type from the input type.
source§

impl From<Number> for Value

source§

fn from(num: Number) -> Self

Converts to this type from the input type.
source§

impl From<ObjectKey> for Value

source§

fn from(key: ObjectKey) -> Self

Converts to this type from the input type.
source§

impl From<String> for Value

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl From<Structure> for Value

source§

fn from(s: Structure) -> Value

Converts to this type from the input type.
source§

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

source§

fn from(value: T) -> Value

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<T: Into<Value>> From<Vec<T>> for Value

source§

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

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(b: bool) -> 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(f: f64) -> Self

Converts to this type from the input type.
source§

impl From<i16> for Value

source§

fn from(n: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for Value

source§

fn from(n: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(n: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for Value

source§

fn from(n: i8) -> Self

Converts to this type from the input type.
source§

impl From<isize> for Value

source§

fn from(n: isize) -> Self

Converts to this type from the input type.
source§

impl From<u16> for Value

source§

fn from(n: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for Value

source§

fn from(n: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for Value

source§

fn from(n: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Value

source§

fn from(n: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for Value

source§

fn from(n: usize) -> Self

Converts to this type from the input type.
source§

impl<K: Into<String>, V: Into<Value>> FromIterator<(K, V)> for Value

source§

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

Creates a value from an iterator. Read more
source§

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

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 Value

§

type Deserializer = ValueDeserializer

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 Value

source§

fn eq(&self, other: &Value) -> 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 Value

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

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