Enum ruma::serde::CanonicalJsonValue [−][src]
pub enum CanonicalJsonValue {
Null,
Bool(bool),
Integer(Int),
String(String),
Array(Vec<CanonicalJsonValue, Global>),
Object(BTreeMap<String, CanonicalJsonValue>),
}
Expand description
Represents a canonical JSON value as per the Matrix specification.
Variants
Represents a JSON null value.
let v: CanonicalJsonValue = json!(null).try_into().unwrap();
Bool(bool)
Represents a JSON boolean.
let v: CanonicalJsonValue = json!(true).try_into().unwrap();
Integer(Int)
Represents a JSON integer.
let v: CanonicalJsonValue = json!(12).try_into().unwrap();
String(String)
Represents a JSON string.
let v: CanonicalJsonValue = json!("a string").try_into().unwrap();
Array(Vec<CanonicalJsonValue, Global>)
Represents a JSON array.
let v: CanonicalJsonValue = json!(["an", "array"]).try_into().unwrap();
Object(BTreeMap<String, CanonicalJsonValue>)
Represents a JSON object.
The map is backed by a BTreeMap to guarantee the sorting of keys.
let v: CanonicalJsonValue = json!({ "an": "object" }).try_into().unwrap();
Implementations
This is supported on crate feature api
only.
api
only.If the CanonicalJsonValue
is a Bool
, return the inner value.
This is supported on crate feature api
only.
api
only.If the CanonicalJsonValue
is an Integer
, return the inner value.
This is supported on crate feature api
only.
api
only.If the CanonicalJsonValue
is a String
, return a reference to the inner value.
This is supported on crate feature api
only.
api
only.If the CanonicalJsonValue
is an Array
, return a reference to the inner value.
This is supported on crate feature api
only.
api
only.If the CanonicalJsonValue
is an Object
, return a reference to the inner value.
This is supported on crate feature api
only.
api
only.If the CanonicalJsonValue
is an Array
, return a mutable reference to the inner value.
This is supported on crate feature api
only.
api
only.If the CanonicalJsonValue
is an Object
, return a mutable reference to the inner value.
This is supported on crate feature api
only.
api
only.Returns true
if the CanonicalJsonValue
is a Bool
.
This is supported on crate feature api
only.
api
only.Returns true
if the CanonicalJsonValue
is an Integer
.
This is supported on crate feature api
only.
api
only.Returns true
if the CanonicalJsonValue
is a String
.
This is supported on crate feature api
only.
api
only.Returns true
if the CanonicalJsonValue
is an Array
.
Trait Implementations
Returns the “default value” for a type. Read more
pub fn deserialize<D>(
deserializer: D
) -> Result<CanonicalJsonValue, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<CanonicalJsonValue, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Display this value as a string.
This Display
implementation is intentionally unaffected by any formatting parameters,
because adding extra whitespace or otherwise pretty-printing it would make it not the
canonical form anymore.
If you want to pretty-print a CanonicalJsonValue
for debugging purposes, use
one of serde_json::{to_string_pretty, to_vec_pretty, to_writer_pretty}
.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for CanonicalJsonValue
impl Send for CanonicalJsonValue
impl Sync for CanonicalJsonValue
impl Unpin for CanonicalJsonValue
impl UnwindSafe for CanonicalJsonValue
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more