Merge JsonObject type aliases

This commit is contained in:
Jonas Platte 2021-09-27 12:55:31 +02:00
parent fde518ea89
commit af250cf108
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
3 changed files with 7 additions and 5 deletions

View File

@ -5,13 +5,12 @@ use std::borrow::Cow;
use ruma_api::ruma_api;
#[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::MxcUri;
use ruma_serde::JsonObject;
#[cfg(feature = "unstable-pre-spec")]
use ruma_serde::StringEnum;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue;
type JsonObject = serde_json::Map<String, JsonValue>;
ruma_api! {
metadata: {
description: "Gets the homeserver's supported login types to authenticate users. Clients should pick one of these and supply it as the type when logging in.",

View File

@ -8,7 +8,7 @@ use ruma_events_macros::EventContent;
#[cfg(feature = "unstable-pre-spec")]
use ruma_identifiers::{DeviceIdBox, UserId};
use ruma_identifiers::{EventId, MxcUri};
use ruma_serde::StringEnum;
use ruma_serde::{JsonObject, StringEnum};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue;
@ -20,8 +20,6 @@ mod content_serde;
pub mod feedback;
mod relation_serde;
type JsonObject = serde_json::Map<String, JsonValue>;
/// This event is used when sending messages in a room.
///
/// Messages are not limited to be text.

View File

@ -4,6 +4,8 @@
#![warn(missing_docs)]
use serde_json::Value as JsonValue;
mod buf;
pub mod can_be_empty;
mod canonical_json;
@ -32,6 +34,9 @@ pub use strings::{
none_as_empty_string,
};
/// The inner type of [`serde_json::Value:::Object`].
pub type JsonObject = serde_json::Map<String, JsonValue>;
/// Check whether a value is equal to its default value.
pub fn is_default<T: Default + PartialEq>(val: &T) -> bool {
*val == T::default()