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
impl Value
Sourcepub fn as_array(&self) -> Option<&Vec<Value>>
pub fn as_array(&self) -> Option<&Vec<Value>>
If the Value
is an Array, returns the associated vector. Returns None
otherwise.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
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.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
If the Value
is a Boolean, represent it as bool if possible. Returns
None otherwise.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
If the Value
is a Number, represent it as f64 if possible. Returns
None otherwise.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
If the Value
is a Number, represent it as i64 if possible. Returns
None otherwise.
Sourcepub fn as_null(&self) -> Option<()>
pub fn as_null(&self) -> Option<()>
If the Value
is a Null, returns (). Returns None otherwise.
Sourcepub fn as_number(&self) -> Option<&Number>
pub fn as_number(&self) -> Option<&Number>
If the Value
is a Number, returns the associated Number. Returns None
otherwise.
Sourcepub fn as_object(&self) -> Option<&Map<String, Value>>
pub fn as_object(&self) -> Option<&Map<String, Value>>
If the Value
is an Object, returns the associated Map. Returns None
otherwise.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut Map<String, Value>>
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.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
If the Value
is a String, returns the associated str. Returns None
otherwise.
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
If the Value
is a Number, represent it as u64 if possible. Returns
None otherwise.
Sourcepub fn is_array(&self) -> bool
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.
Sourcepub fn is_boolean(&self) -> bool
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.
Sourcepub fn is_f64(&self) -> bool
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.
Sourcepub fn is_i64(&self) -> bool
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.
Sourcepub fn is_number(&self) -> bool
pub fn is_number(&self) -> bool
Returns true if the Value
is a Number. Returns false otherwise.
Sourcepub fn is_null(&self) -> bool
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(())
.
Sourcepub fn is_object(&self) -> bool
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.
Sourcepub fn is_string(&self) -> bool
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<D>(deserializer: D) -> Result<Value, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Value, D::Error>where
D: Deserializer<'de>,
Source§impl Format for Value
impl Format for Value
Source§fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>where
W: Write,
fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>where
W: Write,
Source§impl From<Expression> for Value
impl From<Expression> for Value
Source§fn from(expr: Expression) -> Self
fn from(expr: Expression) -> Self
Source§impl From<Value> for Expression
impl From<Value> for Expression
Source§impl<T: Into<Value>> FromIterator<T> for Value
impl<T: Into<Value>> FromIterator<T> for Value
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<'de> IntoDeserializer<'de, Error> for Value
impl<'de> IntoDeserializer<'de, Error> for Value
Source§type Deserializer = ValueDeserializer
type Deserializer = ValueDeserializer
Source§fn into_deserializer(self) -> Self::Deserializer
fn into_deserializer(self) -> Self::Deserializer
impl Eq for Value
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.