[][src]Enum php_literal_parser::Value

pub enum Value {
    Bool(bool),
    Int(i64),
    Float(f64),
    String(String),
    Array(HashMap<Key, Value>),
    Null,
}

Variants

Bool(bool)
Int(i64)
Float(f64)
String(String)
Array(HashMap<Key, Value>)
Null

Implementations

impl Value[src]

A php value, can be either a bool, int, float, string or array note that in php all arrays are associative and thus represented by a map in rust.

You can convert a Value into a regular rust type by pattern matching or using the into_ functions.

Indexing

If the value is a php array, you can directly index into the Value, this will null if the Value is not an array or the key is not found

let value = Value::Array(hashmap!{
    "key".into() => "value".into(),
    10.into() => false.into()
});
assert_eq!(value["key"], "value");
assert_eq!(value[10], false);
assert!(value["not"]["found"].is_null());

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

Check if the value is a bool

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

Check if the value is an integer

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

Check if the value is a float

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

Check if the value is a string

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

Check if the value is an array

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

Check if the value is null

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

Convert the value into a bool if it is one

pub fn into_int(self) -> Option<i64>[src]

Convert the value into a int if it is one

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

Convert the value into a float if it is one

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

Convert the value into a string if it is one

pub fn into_hashmap(self) -> Option<HashMap<Key, Value>>[src]

Convert the value into a hashmap if it is one

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

Get the value as &str if it is a string

Trait Implementations

impl Clone for Value[src]

impl Debug for Value[src]

impl Display for Value[src]

impl<'_> From<&'_ str> for Value[src]

impl From<String> for Value[src]

impl From<bool> for Value[src]

impl From<f64> for Value[src]

impl From<i64> for Value[src]

impl<Q: ?Sized, '_> Index<&'_ Q> for Value where
    Key: Borrow<Q>,
    Q: Eq + Hash
[src]

type Output = Value

The returned type after indexing.

impl Index<Key> for Value[src]

type Output = Value

The returned type after indexing.

impl Index<i64> for Value[src]

type Output = Value

The returned type after indexing.

impl<'_> PartialEq<&'_ str> for Value[src]

impl PartialEq<String> for Value[src]

impl PartialEq<Value> for Value[src]

impl PartialEq<bool> for Value[src]

impl PartialEq<f64> for Value[src]

impl PartialEq<i64> for Value[src]

impl StructuralPartialEq for Value[src]

Auto Trait Implementations

impl RefUnwindSafe for Value

impl Send for Value

impl Sync for Value

impl Unpin for Value

impl UnwindSafe for Value

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> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.