pub enum Value {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec<Value>),
Object(IndexMap<String, Value>),
}
Expand description
A Subgraph JSON value.
Variantsยง
Null
Bool(bool)
Number(Number)
String(String)
Array(Vec<Value>)
Object(IndexMap<String, Value>)
Implementationsยง
sourceยงimpl Value
impl Value
sourcepub fn from_bytes(bytes: impl AsRef<[u8]>) -> Self
pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Self
Parses a new JSON from from some bytes.
sourcepub fn try_from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, ParseError>
pub fn try_from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, ParseError>
Parses a new JSON value from bytes, returning and error on failure.
sourcepub fn as_null(&self) -> Option<()>
pub fn as_null(&self) -> Option<()>
Returns the JSON value as a unit value, or None
if the value is not
null
.
sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the JSON value as a boolean value, or None
if the value is not
true
or false
.
sourcepub fn as_number(&self) -> Option<&Number>
pub fn as_number(&self) -> Option<&Number>
Returns the JSON value as a numeric value, or None
if the value is not
a number.
sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Returns the JSON value as a string value, or None
if the value is not
a string.
Trait Implementationsยง
impl Eq for Value
impl StructuralEq for Value
impl StructuralPartialEq for Value
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ยง
sourceยงimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.