Enum ruma_signatures::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

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

Represents a JSON array.

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

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

impl CanonicalJsonValue[src]

pub fn as_bool(&self) -> Option<bool>[src]

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

pub fn as_integer(&self) -> Option<Int>[src]

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

pub fn as_str(&self) -> Option<&str>[src]

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

pub fn as_array(&self) -> Option<&[CanonicalJsonValue]>[src]

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

pub fn as_object(&self) -> Option<&BTreeMap<String, CanonicalJsonValue>>[src]

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

pub fn as_array_mut(&mut self) -> Option<&mut Vec<CanonicalJsonValue, Global>>[src]

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

pub fn as_object_mut(
    &mut self
) -> Option<&mut BTreeMap<String, CanonicalJsonValue>>
[src]

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

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

Returns true if the CanonicalJsonValue is a Bool.

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

Returns true if the CanonicalJsonValue is an Integer.

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

Returns true if the CanonicalJsonValue is a String.

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

Returns true if the CanonicalJsonValue is an Array.

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

Returns true if the CanonicalJsonValue is an Object.

Trait Implementations

impl Clone for CanonicalJsonValue[src]

pub fn clone(&self) -> CanonicalJsonValue[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for CanonicalJsonValue[src]

pub fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Default for CanonicalJsonValue[src]

pub fn default() -> CanonicalJsonValue[src]

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

impl<'de> Deserialize<'de> for CanonicalJsonValue[src]

pub fn deserialize<D>(
    deserializer: D
) -> Result<CanonicalJsonValue, <D as Deserializer<'de>>::Error> where
    D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Display for CanonicalJsonValue[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

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

impl From<BTreeMap<String, CanonicalJsonValue>> for CanonicalJsonValue[src]

pub fn from(val: BTreeMap<String, CanonicalJsonValue>) -> CanonicalJsonValue[src]

Performs the conversion.

impl From<Int> for CanonicalJsonValue[src]

pub fn from(val: Int) -> CanonicalJsonValue[src]

Performs the conversion.

impl From<String> for CanonicalJsonValue[src]

pub fn from(val: String) -> CanonicalJsonValue[src]

Performs the conversion.

impl From<Vec<CanonicalJsonValue, Global>> for CanonicalJsonValue[src]

pub fn from(val: Vec<CanonicalJsonValue, Global>) -> CanonicalJsonValue[src]

Performs the conversion.

impl From<bool> for CanonicalJsonValue[src]

pub fn from(val: bool) -> CanonicalJsonValue[src]

Performs the conversion.

impl PartialEq<BTreeMap<String, CanonicalJsonValue>> for CanonicalJsonValue[src]

pub fn eq(&self, other: &BTreeMap<String, CanonicalJsonValue>) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<CanonicalJsonValue> for CanonicalJsonValue[src]

pub fn eq(&self, other: &CanonicalJsonValue) -> bool[src]

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

pub fn ne(&self, other: &CanonicalJsonValue) -> bool[src]

This method tests for !=.

impl PartialEq<Int> for CanonicalJsonValue[src]

pub fn eq(&self, other: &Int) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<String> for CanonicalJsonValue[src]

pub fn eq(&self, other: &String) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<Vec<CanonicalJsonValue, Global>> for CanonicalJsonValue[src]

pub fn eq(&self, other: &Vec<CanonicalJsonValue, Global>) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<bool> for CanonicalJsonValue[src]

pub fn eq(&self, other: &bool) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl Serialize for CanonicalJsonValue[src]

pub fn serialize<S>(
    &self,
    serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl TryFrom<Value> for CanonicalJsonValue[src]

type Error = Error

The type returned in the event of a conversion error.

pub fn try_from(
    val: Value
) -> Result<CanonicalJsonValue, <CanonicalJsonValue as TryFrom<Value>>::Error>
[src]

Performs the conversion.

impl Eq for CanonicalJsonValue[src]

impl StructuralEq for CanonicalJsonValue[src]

impl StructuralPartialEq for CanonicalJsonValue[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]