Enum nop_json::Value[][src]

pub enum Value {
    Null,
    Bool(bool),
    Number(u64i16bool),
    String(String),
    Array(Vec<Value>),
    Object(HashMap<String, Value>),
}

Type to store any JSON node.

Numbers are represented by 3 parts: mantissa, exponent, sign.

Many built-in types can be converted to Value.

use nop_json::Value;
use std::convert::TryInto;

let v0: Value = 3u32.try_into().unwrap();
let v1: Value = vec![true, false, true].try_into().unwrap();
assert_eq!(v0, Value::Number(3, 0, false));
assert_eq!(v1, Value::Array(vec![Value::Bool(true), Value::Bool(false), Value::Bool(true)]));

And the Value can be converted to many types.

use nop_json::Value;
use std::convert::TryInto;

let v0: u32 = Value::Number(3, 0, false).try_into().unwrap();
let v1: Vec<bool> = Value::Array(vec![Value::Bool(true), Value::Bool(false), Value::Bool(true)]).try_into().unwrap();
assert_eq!(v0, 3u32);
assert_eq!(v1, vec![true, false, true]);

Variants

Null
Bool(bool)
Number(u64i16bool)
String(String)
Array(Vec<Value>)
Object(HashMap<String, Value>)

Implementations

impl Value[src]

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

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

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

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

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

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

Trait Implementations

impl Clone for Value[src]

impl Debug for Value[src]

impl DebugToJson for Value[src]

impl Display for Value[src]

impl FromStr for Value[src]

type Err = ()

The associated error which can be returned from parsing.

impl<'a> Index<&'a str> for Value[src]

type Output = Value

The returned type after indexing.

impl PartialEq<Value> for Value[src]

impl StructuralPartialEq for Value[src]

impl TryFrom<()> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, ()>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, String>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, bool>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, char>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, i16>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, i32>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, i64>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, i8>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, isize>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, u16>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, u32>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, u64>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, u8>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<BTreeMap<String, usize>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, (), RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, String, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, Value, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, bool, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, char, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, i16, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, i32, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, i64, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, i8, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, isize, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, u16, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, u32, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, u64, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, u8, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<HashMap<String, usize, RandomState>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<()>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<String>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<bool>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<char>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<i16>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<i32>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<i64>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<i8>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<isize>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<u16>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<u32>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<u64>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<u8>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<LinkedList<usize>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<String> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<(), Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<String, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<Value, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<bool, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<char, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<i16, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<i32, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<i64, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<i8, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<isize, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<u16, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<u32, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<u64, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<u8, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<Vec<usize, Global>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<()>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<String>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<bool>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<char>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<i16>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<i32>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<i64>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<i8>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<isize>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<u16>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<u32>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<u64>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<u8>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<VecDeque<usize>> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<bool> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<char> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<i16> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<i32> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<i64> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<i8> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<isize> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<u16> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<u32> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<u64> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<u8> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<usize> for Value[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFromJson for Value[src]

impl<W: Write> WriteToJson<W> 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.