Enum php_literal_parser::Value [−][src]
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)
Implementations
impl Value
[src]
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
pub fn as_int(&self) -> Option<i64>
[src]
Get the value as i64 if it is an int
pub fn as_float(&self) -> Option<f64>
[src]
Get the value as f64 if it is a float
pub fn iter(&self) -> impl Iterator<Item = (&Key, &Value)>
[src]
Iterate over array key and value pairs if it is an array
pub fn keys(&self) -> impl Iterator<Item = &Key>
[src]
Iterate over array keys if it is an array
pub fn values(&self) -> impl Iterator<Item = &Value>
[src]
Iterate over array values if it is an array
Trait Implementations
impl<'de> Deserialize<'de> for Value
[src]
impl<'de> Deserialize<'de> for Value
[src]fn deserialize<D>(deserializer: D) -> Result<Value, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl StructuralPartialEq for Value
[src]
impl StructuralPartialEq for Value
[src]Auto Trait Implementations
impl RefUnwindSafe for Value
impl RefUnwindSafe for Value
impl UnwindSafe for Value
impl UnwindSafe for Value