[][src]Enum jmespatch::Variable

pub enum Variable {
    Null,
    String(String),
    Bool(bool),
    Number(Number),
    Array(Vec<Rcvar>),
    Object(BTreeMap<String, Rcvar>),
    Expref(Ast),
}

JMESPath variable.

Variants

Null
String(String)
Bool(bool)
Number(Number)
Array(Vec<Rcvar>)
Expref(Ast)

Methods

impl Variable[src]

pub fn from_serializable<T>(value: T) -> Result<Variable, JmespathError> where
    T: Serialize
[src]

Shortcut function to encode a T into a JMESPath Variable

pub fn from_json(s: &str) -> Result<Self, String>[src]

Create a JMESPath Variable from a JSON encoded string.

pub fn is_array(&self) -> bool[src]

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

pub fn as_array(&self) -> Option<&Vec<Rcvar>>[src]

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

pub fn is_object(&self) -> bool[src]

Returns true if the value is an Object.

pub fn as_object(&self) -> Option<&BTreeMap<String, Rcvar>>[src]

If the value is an Object, returns the associated BTreeMap. Returns None otherwise.

pub fn is_string(&self) -> bool[src]

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

pub fn as_string(&self) -> Option<&String>[src]

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

pub fn is_number(&self) -> bool[src]

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

pub fn as_number(&self) -> Option<f64>[src]

If the value is a number, return or cast it to a f64. Returns None otherwise.

pub fn is_boolean(&self) -> bool[src]

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

pub fn as_boolean(&self) -> Option<bool>[src]

If the value is a Boolean, returns the associated bool. Returns None otherwise.

pub fn is_null(&self) -> bool[src]

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

pub fn as_null(&self) -> Option<()>[src]

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

pub fn is_expref(&self) -> bool[src]

Returns true if the value is an expression reference. Returns false otherwise.

pub fn as_expref(&self) -> Option<&Ast>[src]

If the value is an expression reference, returns the associated Ast node. Returns None otherwise.

pub fn get_field(&self, key: &str) -> Rcvar[src]

If the value is an object, returns the value associated with the provided key. Otherwise, returns Null.

pub fn get_index(&self, index: usize) -> Rcvar[src]

If the value is an array, then gets an array value by index. Otherwise returns Null.

pub fn get_negative_index(&self, index: usize) -> Rcvar[src]

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).

pub fn is_truthy(&self) -> bool[src]

Returns true or false based on if the Variable value is considered truthy.

pub fn get_type(&self) -> JmespathType[src]

Returns the JMESPath type name of a Variable value.

pub fn compare(&self, cmp: &Comparator, value: &Variable) -> Option<bool>[src]

Compares two Variable values using a comparator.

pub fn slice(
    &self,
    start: Option<i32>,
    stop: Option<i32>,
    step: i32
) -> Option<Vec<Rcvar>>
[src]

Returns a slice of the variable if the variable is an array.

Trait Implementations

impl Clone for Variable[src]

impl Debug for Variable[src]

impl<'de> Deserialize<'de> for Variable[src]

Serde deserialization for Variable

impl<'de> Deserializer<'de> for Variable[src]

type Error = Error

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

impl Display for Variable[src]

Write the JSON representation of a value, converting expref to a JSON string containing the debug dump of the expref variable.

impl Eq for Variable[src]

impl Ord for Variable[src]

impl PartialEq<Variable> for Variable[src]

Implement PartialEq for looser floating point comparisons.

impl PartialOrd<Variable> for Variable[src]

Implement PartialOrd so that Ast can be in the PartialOrd of Variable.

impl Serialize for Variable[src]

impl<'a> TryFrom<&'a Value> for Variable[src]

Convert a borrowed Value to a Variable.

type Error = JmespathError

The type returned in the event of a conversion error.

impl TryFrom<Value> for Variable[src]

Slightly optimized method for converting from an owned Value.

type Error = JmespathError

The type returned in the event of a conversion error.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<'a, T> ToJmespath for T where
    T: Serialize
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.