logo
pub enum CanonicalJsonValue {
    Null,
    Bool(bool),
    Integer(Int),
    String(String),
    Array(Vec<CanonicalJsonValue>),
    Object(Object),
}
Expand description

Represents a canonical JSON value as per the Matrix specification.

Variants

Null

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>)

Represents a JSON array.

let v: CanonicalJsonValue = json!(["an", "array"]).try_into().unwrap();

Object(Object)

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

If the CanonicalJsonValue is a Bool, return the inner value.

If the CanonicalJsonValue is an Integer, return the inner value.

If the CanonicalJsonValue is a String, return a reference to the inner value.

If the CanonicalJsonValue is an Array, return a reference to the inner value.

If the CanonicalJsonValue is an Object, return a reference to the inner value.

If the CanonicalJsonValue is an Array, return a mutable reference to the inner value.

If the CanonicalJsonValue is an Object, return a mutable reference to the inner value.

Returns true if the CanonicalJsonValue is a Bool.

Returns true if the CanonicalJsonValue is an Integer.

Returns true if the CanonicalJsonValue is a String.

Returns true if the CanonicalJsonValue is an Array.

Returns true if the CanonicalJsonValue is an Object.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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}.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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