[][src]Trait value_trait::Value

pub trait Value: Sized + Index<usize> + PartialEq<i8> + PartialEq<i16> + PartialEq<i32> + PartialEq<i64> + PartialEq<i128> + PartialEq<u8> + PartialEq<u16> + PartialEq<u32> + PartialEq<u64> + PartialEq<u128> + PartialEq<f32> + PartialEq<f64> + PartialEq<String> + PartialEq<bool> + PartialEq<()> {
    type Key: Hash + Eq;
    type Array: Array<Element = Self>;
    type Object: Object<Key = Self::Key, Element = Self>;
#[must_use]    fn value_type(&self) -> ValueType;
#[must_use] fn is_null(&self) -> bool;
#[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>
    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> { ... }
#[must_use] fn is_bool(&self) -> bool { ... }
#[must_use] fn as_i128(&self) -> Option<i128> { ... }
#[must_use] fn is_i128(&self) -> bool { ... }
#[must_use] fn is_i64(&self) -> bool { ... }
#[must_use] fn as_i32(&self) -> Option<i32> { ... }
#[must_use] fn is_i32(&self) -> bool { ... }
#[must_use] fn as_i16(&self) -> Option<i16> { ... }
#[must_use] fn is_i16(&self) -> bool { ... }
#[must_use] fn as_i8(&self) -> Option<i8> { ... }
#[must_use] fn is_i8(&self) -> bool { ... }
#[must_use] fn as_u128(&self) -> Option<u128> { ... }
#[must_use] fn is_u128(&self) -> bool { ... }
#[must_use] fn is_u64(&self) -> bool { ... }
#[must_use] fn as_usize(&self) -> Option<usize> { ... }
#[must_use] fn is_usize(&self) -> bool { ... }
#[must_use] fn as_u32(&self) -> Option<u32> { ... }
#[must_use] fn is_u32(&self) -> bool { ... }
#[must_use] fn as_u16(&self) -> Option<u16> { ... }
#[must_use] fn is_u16(&self) -> bool { ... }
#[must_use] fn as_u8(&self) -> Option<u8> { ... }
#[must_use] fn is_u8(&self) -> bool { ... }
#[must_use] fn is_f64(&self) -> bool { ... }
#[must_use] fn cast_f64(&self) -> Option<f64> { ... }
#[must_use] fn is_f64_castable(&self) -> bool { ... }
#[must_use] fn as_f32(&self) -> Option<f32> { ... }
#[must_use] fn is_f32(&self) -> bool { ... }
#[must_use] fn is_str(&self) -> bool { ... }
#[must_use] fn is_array(&self) -> bool { ... }
#[must_use] fn is_object(&self) -> bool { ... } }

The Value exposes common interface for values, this allows using both BorrowedValue and OwnedValue nearly interchangable

Associated Types

type Key: Hash + Eq

The type for Objects

type Array: Array<Element = Self>

The array structure

type Object: Object<Key = Self::Key, Element = Self>

The object structure

Loading content...

Required methods

#[must_use]fn value_type(&self) -> ValueType

Returns the type of the current Valye

#[must_use]fn is_null(&self) -> bool

returns true if the current value is null

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

Tries to represent the value as a bool

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

Tries to represent the value as an i64

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

Tries to represent the value as an u64

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

Tries to represent the value as a f64

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

Tries to represent the value as a &str

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

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

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

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> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq + Ord

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

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>

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 is_bool(&self) -> bool

returns true if the current value a bool

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

Tries to represent the value as an i128

#[must_use]fn is_i128(&self) -> bool

returns true if the current value can be represented as a i128

#[must_use]fn is_i64(&self) -> bool

returns true if the current value can be represented as a i64

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

Tries to represent the value as an i32

#[must_use]fn is_i32(&self) -> bool

returns true if the current value can be represented as a i32

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

Tries to represent the value as an i16

#[must_use]fn is_i16(&self) -> bool

returns true if the current value can be represented as a i16

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

Tries to represent the value as an i8

#[must_use]fn is_i8(&self) -> bool

returns true if the current value can be represented as a i8

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

Tries to represent the value as an u128

#[must_use]fn is_u128(&self) -> bool

returns true if the current value can be represented as a u128

#[must_use]fn is_u64(&self) -> bool

returns true if the current value can be represented as a u64

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

Tries to represent the value as an usize

#[must_use]fn is_usize(&self) -> bool

returns true if the current value can be represented as a usize

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

Tries to represent the value as an u32

#[must_use]fn is_u32(&self) -> bool

returns true if the current value can be represented as a u32

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

Tries to represent the value as an u16

#[must_use]fn is_u16(&self) -> bool

returns true if the current value can be represented as a u16

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

Tries to represent the value as an u8

#[must_use]fn is_u8(&self) -> bool

returns true if the current value can be represented as a u8

#[must_use]fn is_f64(&self) -> bool

returns true if the current value can be represented as a f64

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

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

#[must_use]fn is_f64_castable(&self) -> bool

returns true if the current value can be cast into a f64

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

Tries to represent the value as a f32

#[must_use]fn is_f32(&self) -> bool

returns true if the current value can be represented as a f64

#[must_use]fn is_str(&self) -> bool

returns true if the current value can be represented as a str

#[must_use]fn is_array(&self) -> bool

returns true if the current value can be represented as an array

#[must_use]fn is_object(&self) -> bool

returns true if the current value can be represented as an object

Loading content...

Implementors

impl Value for StaticNode[src]

type Key = String

type Array = Vec<StaticNode>

type Object = HashMap<String, StaticNode>

Loading content...