Enum json_syntax::Value
source · [−]pub enum Value<S, P = Span> {
Null,
Boolean(bool),
Number(NumberBuf),
String(String),
Array(Array<S, P>),
Object(Object<S, P>),
}
Expand description
Value.
The two types parameters are used to locate/map values inside the source
file.
The S
parameter is the type used to identify the source file (generally
a string slice, a path, or an index).
The P
parameter is the type used to locate the value inside the file.
By default the locspan::Span
type is used, since it is what the parser
uses.
Comparison
This type implements the usual comparison traits PartialEq
, Eq
,
PartialOrd
and Ord
. However these implementations will also compare the
code mapping information (source file and span).
If you want to do comparisons while ignoring this information, you can use
the locspan::Stripped
type.
Variants
Null
null
.
Boolean(bool)
Boolean true
or false
.
Number(NumberBuf)
Number.
String(String)
String.
Array(Array<S, P>)
Array.
Object(Object<S, P>)
Object.
Implementations
sourceimpl<S, P> Value<S, P>
impl<S, P> Value<S, P>
pub fn is_null(&self) -> bool
pub fn is_boolean(&self) -> bool
pub fn is_number(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_array(&self) -> bool
pub fn is_object(&self) -> bool
pub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean_mut(&mut self) -> Option<&mut bool>
pub fn as_number(&self) -> Option<&Number>
pub fn as_number_mut(&mut self) -> Option<&mut NumberBuf>
pub fn as_string(&self) -> Option<&str>
pub fn as_string_mut(&mut self) -> Option<&mut String>
pub fn as_array(&self) -> Option<&[Loc<Self, S, P>]>
pub fn as_array_mut(&mut self) -> Option<&mut Array<S, P>>
pub fn as_object(&self) -> Option<&Object<S, P>>
pub fn as_object_mut(&mut self) -> Option<&mut Object<S, P>>
pub fn into_boolean(self) -> Option<bool>
pub fn into_number(self) -> Option<NumberBuf>
pub fn into_string(self) -> Option<String>
pub fn into_array(self) -> Option<Array<S, P>>
pub fn into_object(self) -> Option<Object<S, P>>
Trait Implementations
sourceimpl<S: Ord, P: Ord> Ord for Value<S, P>
impl<S: Ord, P: Ord> Ord for Value<S, P>
sourceimpl<F: Clone> Parse<F> for Value<F>
impl<F: Clone> Parse<F> for Value<F>
fn parse_in<E, C>(
parser: &mut Parser<F, E, C>,
context: Context
) -> Result<Loc<Self, F>, Loc<Error<E, F>, F>> where
C: Iterator<Item = Result<DecodedChar, E>>,
fn parse<E, C>(file: F, chars: C) -> Result<Loc<Self, F>, Loc<Error<E, F>, F>> where
C: Iterator<Item = Result<DecodedChar, E>>,
fn parse_with<E, C>(
file: F,
chars: C,
options: Options
) -> Result<Loc<Self, F>, Loc<Error<E, F>, F>> where
C: Iterator<Item = Result<DecodedChar, E>>,
sourceimpl<S: PartialOrd, P: PartialOrd> PartialOrd<Value<S, P>> for Value<S, P>
impl<S: PartialOrd, P: PartialOrd> PartialOrd<Value<S, P>> for Value<S, P>
sourcefn partial_cmp(&self, other: &Value<S, P>) -> Option<Ordering>
fn partial_cmp(&self, other: &Value<S, P>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<S, P> StrippedHash for Value<S, P>
impl<S, P> StrippedHash for Value<S, P>
fn stripped_hash<H: Hasher>(&self, state: &mut H)
sourceimpl<S, P> StrippedOrd for Value<S, P>
impl<S, P> StrippedOrd for Value<S, P>
fn stripped_cmp(&self, other: &Self) -> Ordering
sourceimpl<S, P> StrippedPartialEq<Value<S, P>> for Value<S, P>
impl<S, P> StrippedPartialEq<Value<S, P>> for Value<S, P>
fn stripped_eq(&self, other: &Self) -> bool
sourceimpl<S, P> StrippedPartialOrd<Value<S, P>> for Value<S, P>
impl<S, P> StrippedPartialOrd<Value<S, P>> for Value<S, P>
fn stripped_partial_cmp(&self, other: &Self) -> Option<Ordering>
impl<S: Eq, P: Eq> Eq for Value<S, P>
impl<S, P> StrippedEq for Value<S, P>
impl<S, P> StructuralEq for Value<S, P>
impl<S, P> StructuralPartialEq for Value<S, P>
Auto Trait Implementations
impl<S, P> RefUnwindSafe for Value<S, P> where
P: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, P> Send for Value<S, P> where
P: Send,
S: Send,
impl<S, P> Sync for Value<S, P> where
P: Sync,
S: Sync,
impl<S, P> Unpin for Value<S, P> where
P: Unpin,
S: Unpin,
impl<S, P> UnwindSafe for Value<S, P> where
P: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more