pub enum Variable {
Null,
String(String),
Bool(bool),
Number(Number),
Array(Vec<Rcvar>),
Object(BTreeMap<String, Rcvar>),
Expref(Ast),
}
Expand description
JMESPath variable.
Variants
Null
String(String)
Bool(bool)
Number(Number)
Array(Vec<Rcvar>)
Object(BTreeMap<String, Rcvar>)
Expref(Ast)
Implementations
sourceimpl Variable
impl Variable
sourcepub fn from_serializable<T>(value: T) -> Result<Variable, JmespathError> where
T: Serialize,
pub fn from_serializable<T>(value: T) -> Result<Variable, JmespathError> where
T: Serialize,
Shortcut function to encode a T
into a JMESPath Variable
sourcepub fn from_json(s: &str) -> Result<Self, String>
pub fn from_json(s: &str) -> Result<Self, String>
Create a JMESPath Variable from a JSON encoded string.
sourcepub fn is_array(&self) -> bool
pub fn is_array(&self) -> bool
Returns true if the Variable is an Array. Returns false otherwise.
sourcepub fn as_array(&self) -> Option<&Vec<Rcvar>>
pub fn as_array(&self) -> Option<&Vec<Rcvar>>
If the Variable value is an Array, returns the associated vector. Returns None otherwise.
sourcepub fn as_object(&self) -> Option<&BTreeMap<String, Rcvar>>
pub fn as_object(&self) -> Option<&BTreeMap<String, Rcvar>>
If the value is an Object, returns the associated BTreeMap. Returns None otherwise.
sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Returns true if the value is a String. Returns false otherwise.
sourcepub fn as_string(&self) -> Option<&String>
pub fn as_string(&self) -> Option<&String>
If the value is a String, returns the associated str. Returns None otherwise.
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 as_number(&self) -> Option<f64>
pub fn as_number(&self) -> Option<f64>
If the value is a number, return or cast it to a f64. Returns None otherwise.
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if the value is a Boolean. Returns false otherwise.
sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
If the value is a Boolean, returns the associated bool. 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 is_expref(&self) -> bool
pub fn is_expref(&self) -> bool
Returns true if the value is an expression reference. Returns false otherwise.
sourcepub fn as_expref(&self) -> Option<&Ast>
pub fn as_expref(&self) -> Option<&Ast>
If the value is an expression reference, returns the associated Ast node. Returns None otherwise.
sourcepub fn get_field(&self, key: &str) -> Rcvar
pub fn get_field(&self, key: &str) -> Rcvar
If the value is an object, returns the value associated with the provided key. Otherwise, returns Null.
sourcepub fn get_index(&self, index: usize) -> Rcvar
pub fn get_index(&self, index: usize) -> Rcvar
If the value is an array, then gets an array value by index. Otherwise returns Null.
sourcepub fn get_negative_index(&self, index: usize) -> Rcvar
pub fn get_negative_index(&self, index: usize) -> Rcvar
Retrieves an index from the end of an array.
Returns Null if not an array or if the index is not present. The formula for determining the index position is length - index (i.e., an index of 0 or 1 is treated as the end of the array).
sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
Returns true or false based on if the Variable value is considered truthy.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Variable
impl<'de> Deserialize<'de> for Variable
Serde deserialization for Variable
sourcefn deserialize<D>(deserializer: D) -> Result<Variable, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Variable, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'de> Deserializer<'de> for Variable
impl<'de> Deserializer<'de> for Variable
type Error = Error
type Error = Error
The error type that can be returned if some error occurs during deserialization. Read more
sourcefn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, 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
sourcefn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Error> where
V: Visitor<'de>,
Hint that the Deserialize
type is expecting an optional value. Read more
sourcefn deserialize_enum<V>(
self,
_name: &str,
_variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
fn deserialize_enum<V>(
self,
_name: &str,
_variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Error> where
V: Visitor<'de>,
Hint that the Deserialize
type is expecting an enum value with a
particular name and possible variants. Read more
sourcefn deserialize_newtype_struct<V>(
self,
_name: &'static str,
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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. Read more
sourcefn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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
sourcefn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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
sourcefn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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
sourcefn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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
sourcefn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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.
sourcefn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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. Read more
sourcefn deserialize_tuple_struct<V>(
self,
name: &'static str,
len: usize,
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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. Read more
sourcefn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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. Read more
sourcefn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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. Read more
sourcefn deserialize_tuple<V>(
self,
len: usize,
visitor: V
) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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. Read more
sourcefn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error> where
V: Visitor<'de>,
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
sourcefn deserialize_i128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
fn deserialize_i128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
Hint that the Deserialize
type is expecting an i128
value. Read more
sourcefn deserialize_u128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
fn deserialize_u128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error> where
V: Visitor<'de>,
Hint that the Deserialize
type is expecting an u128
value. Read more
sourcefn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Determine whether Deserialize
implementations should expect to
deserialize their human-readable form. Read more
sourceimpl Display for Variable
impl Display for Variable
Write the JSON representation of a value, converting expref to a JSON string containing the debug dump of the expref variable.
sourceimpl Ord for Variable
impl Ord for Variable
sourceimpl PartialEq<Variable> for Variable
impl PartialEq<Variable> for Variable
Implement PartialEq for looser floating point comparisons.
sourceimpl PartialOrd<Variable> for Variable
impl PartialOrd<Variable> for Variable
Implement PartialOrd so that Ast can be in the PartialOrd of Variable.
sourcefn partial_cmp(&self, other: &Variable) -> Option<Ordering>
fn partial_cmp(&self, other: &Variable) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
sourcefn lt(&self, other: &Variable) -> bool
fn lt(&self, other: &Variable) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
sourcefn le(&self, other: &Variable) -> bool
fn le(&self, other: &Variable) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Variable
Auto Trait Implementations
impl RefUnwindSafe for Variable
impl !Send for Variable
impl !Sync for Variable
impl Unpin for Variable
impl UnwindSafe for Variable
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, T> ToJmespath for T where
T: Serialize,
impl<'a, T> ToJmespath for T where
T: Serialize,
fn to_jmespath(self) -> Result<Rcvar, JmespathError>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more