Trait value_trait::ValueAccess[][src]

pub trait ValueAccess: Sized {
    type Target: ValueAccess;
    type Key: Hash + Eq;
    type Array: Array<Element = Self::Target>;
    type Object: Object<Key = Self::Key, Element = Self::Target>;
#[must_use]    fn as_bool(&self) -> Option<bool>;
#[must_use] fn as_i64(&self) -> Option<i64>;
#[must_use] fn as_u64(&self) -> Option<u64>;
#[must_use] fn as_f64(&self) -> Option<f64>;
#[must_use] fn as_str(&self) -> Option<&str>;
#[must_use] fn as_array(&self) -> Option<&Self::Array>;
#[must_use] fn as_object(&self) -> Option<&Self::Object>; #[must_use] fn get<Q: ?Sized>(&self, k: &Q) -> Option<&Self::Target>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn get_idx(&self, i: usize) -> Option<&Self::Target> { ... }
#[must_use] fn get_bool<Q: ?Sized>(&self, k: &Q) -> Option<bool>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_i128(&self) -> Option<i128> { ... }
#[must_use] fn get_i128<Q: ?Sized>(&self, k: &Q) -> Option<i128>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn get_i64<Q: ?Sized>(&self, k: &Q) -> Option<i64>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_i32(&self) -> Option<i32> { ... }
#[must_use] fn get_i32<Q: ?Sized>(&self, k: &Q) -> Option<i32>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_i16(&self) -> Option<i16> { ... }
#[must_use] fn get_i16<Q: ?Sized>(&self, k: &Q) -> Option<i16>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_i8(&self) -> Option<i8> { ... }
#[must_use] fn get_i8<Q: ?Sized>(&self, k: &Q) -> Option<i8>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_u128(&self) -> Option<u128> { ... }
#[must_use] fn get_u128<Q: ?Sized>(&self, k: &Q) -> Option<u128>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn get_u64<Q: ?Sized>(&self, k: &Q) -> Option<u64>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_usize(&self) -> Option<usize> { ... }
#[must_use] fn get_usize<Q: ?Sized>(&self, k: &Q) -> Option<usize>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_u32(&self) -> Option<u32> { ... }
#[must_use] fn get_u32<Q: ?Sized>(&self, k: &Q) -> Option<u32>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_u16(&self) -> Option<u16> { ... }
#[must_use] fn get_u16<Q: ?Sized>(&self, k: &Q) -> Option<u16>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_u8(&self) -> Option<u8> { ... }
#[must_use] fn get_u8<Q: ?Sized>(&self, k: &Q) -> Option<u8>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn get_f64<Q: ?Sized>(&self, k: &Q) -> Option<f64>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn cast_f64(&self) -> Option<f64> { ... }
#[must_use] fn as_f32(&self) -> Option<f32> { ... }
#[must_use] fn get_f32<Q: ?Sized>(&self, k: &Q) -> Option<f32>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn as_char(&self) -> Option<char> { ... }
#[must_use] fn get_str<Q: ?Sized>(&self, k: &Q) -> Option<&str>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn get_array<Q: ?Sized>(
        &self,
        k: &Q
    ) -> Option<&<Self::Target as ValueAccess>::Array>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... }
#[must_use] fn get_object<Q: ?Sized>(
        &self,
        k: &Q
    ) -> Option<&<Self::Target as ValueAccess>::Object>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq + Ord
, { ... } }

Trait to allow accessing data inside a Value

Associated Types

type Target: ValueAccess[src]

The target for nested lookups

type Key: Hash + Eq[src]

The type for Objects

type Array: Array<Element = Self::Target>[src]

The array structure

type Object: Object<Key = Self::Key, Element = Self::Target>[src]

The object structure

Loading content...

Required methods

#[must_use]fn as_bool(&self) -> Option<bool>[src]

Tries to represent the value as a bool

#[must_use]fn as_i64(&self) -> Option<i64>[src]

Tries to represent the value as an i64

#[must_use]fn as_u64(&self) -> Option<u64>[src]

Tries to represent the value as an u64

#[must_use]fn as_f64(&self) -> Option<f64>[src]

Tries to represent the value as a f64

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

Tries to represent the value as a &str

#[must_use]fn as_array(&self) -> Option<&Self::Array>[src]

Tries to represent the value as an array and returns a refference to it

#[must_use]fn as_object(&self) -> Option<&Self::Object>[src]

Tries to represent the value as an object and returns a refference to it

Loading content...

Provided methods

#[must_use]fn get<Q: ?Sized>(&self, k: &Q) -> Option<&Self::Target> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Gets a ref to a value based on a key, returns None if the current Value isn’t an Object or doesn’t contain the key it was asked for.

#[must_use]fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Checks if a Value contains a given key. This will return flase if Value isn’t an object

#[must_use]fn get_idx(&self, i: usize) -> Option<&Self::Target>[src]

Gets a ref to a value based on n index, returns None if the current Value isn’t an Array or doesn’t contain the index it was asked for.

#[must_use]fn get_bool<Q: ?Sized>(&self, k: &Q) -> Option<bool> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a bool

#[must_use]fn as_i128(&self) -> Option<i128>[src]

Tries to represent the value as an i128

#[must_use]fn get_i128<Q: ?Sized>(&self, k: &Q) -> Option<i128> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a i128

#[must_use]fn get_i64<Q: ?Sized>(&self, k: &Q) -> Option<i64> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a i64

#[must_use]fn as_i32(&self) -> Option<i32>[src]

Tries to represent the value as an i32

#[must_use]fn get_i32<Q: ?Sized>(&self, k: &Q) -> Option<i32> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a i32

#[must_use]fn as_i16(&self) -> Option<i16>[src]

Tries to represent the value as an i16

#[must_use]fn get_i16<Q: ?Sized>(&self, k: &Q) -> Option<i16> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a i16

#[must_use]fn as_i8(&self) -> Option<i8>[src]

Tries to represent the value as an i8

#[must_use]fn get_i8<Q: ?Sized>(&self, k: &Q) -> Option<i8> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a i8

#[must_use]fn as_u128(&self) -> Option<u128>[src]

Tries to represent the value as an u128

#[must_use]fn get_u128<Q: ?Sized>(&self, k: &Q) -> Option<u128> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a u128

#[must_use]fn get_u64<Q: ?Sized>(&self, k: &Q) -> Option<u64> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a u64

#[must_use]fn as_usize(&self) -> Option<usize>[src]

Tries to represent the value as an usize

#[must_use]fn get_usize<Q: ?Sized>(&self, k: &Q) -> Option<usize> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a usize

#[must_use]fn as_u32(&self) -> Option<u32>[src]

Tries to represent the value as an u32

#[must_use]fn get_u32<Q: ?Sized>(&self, k: &Q) -> Option<u32> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a u32

#[must_use]fn as_u16(&self) -> Option<u16>[src]

Tries to represent the value as an u16

#[must_use]fn get_u16<Q: ?Sized>(&self, k: &Q) -> Option<u16> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a u16

#[must_use]fn as_u8(&self) -> Option<u8>[src]

Tries to represent the value as an u8

#[must_use]fn get_u8<Q: ?Sized>(&self, k: &Q) -> Option<u8> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a u8

#[must_use]fn get_f64<Q: ?Sized>(&self, k: &Q) -> Option<f64> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a f64

#[must_use]fn cast_f64(&self) -> Option<f64>[src]

Casts the current value to a f64 if possible, this will turn integer values into floats.

#[must_use]fn as_f32(&self) -> Option<f32>[src]

Tries to represent the value as a f32

#[must_use]fn get_f32<Q: ?Sized>(&self, k: &Q) -> Option<f32> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a f32

#[must_use]fn as_char(&self) -> Option<char>[src]

Tries to represent the value as a Char

#[must_use]fn get_str<Q: ?Sized>(&self, k: &Q) -> Option<&str> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a str

#[must_use]fn get_array<Q: ?Sized>(
    &self,
    k: &Q
) -> Option<&<Self::Target as ValueAccess>::Array> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a array

#[must_use]fn get_object<Q: ?Sized>(
    &self,
    k: &Q
) -> Option<&<Self::Target as ValueAccess>::Object> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord
[src]

Tries to get an element of an object as a object

Loading content...

Implementations on Foreign Types

impl<V> ValueAccess for Option<V> where
    V: ValueAccess
[src]

type Target = V::Target

type Key = V::Key

type Array = V::Array

type Object = V::Object

impl<V, E> ValueAccess for Result<V, E> where
    V: ValueAccess
[src]

type Target = V::Target

type Key = V::Key

type Array = V::Array

type Object = V::Object

impl<V> ValueAccess for &V where
    V: ValueAccess
[src]

type Target = V::Target

type Key = V::Key

type Array = V::Array

type Object = V::Object

Loading content...

Implementors

impl ValueAccess for StaticNode[src]

type Target = StaticNode

type Key = String

type Array = Vec<StaticNode>

type Object = HashMap<String, StaticNode>

Loading content...