common: Merge ruma-serde into ruma-common

This commit is contained in:
Kévin Commaille 2022-03-10 12:11:00 +01:00 committed by GitHub
parent bdd54d1dd3
commit bdcf07be87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
226 changed files with 441 additions and 595 deletions

View File

@ -22,7 +22,6 @@ server = []
[dependencies]
ruma-client-api = { version = "0.13.0", path = "../ruma-client-api", features = ["client"], optional = true }
ruma-common = { version = "0.8.0", path = "../ruma-common", features = ["api", "events"] }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
serde = { version = "1.0.118", features = ["derive"] }
serde_json = "1.0.61"
tracing = { version = "0.1.25", optional = true }

View File

@ -7,8 +7,7 @@ pub mod v1 {
//!
//! [spec]: https://spec.matrix.org/v1.2/application-service-api/#put_matrixappv1transactionstxnid
use ruma_common::{api::ruma_api, events::AnyRoomEvent, TransactionId};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, events::AnyRoomEvent, serde::Raw, TransactionId};
ruma_api! {
metadata: {

View File

@ -29,7 +29,6 @@ js_int = { version = "0.2.0", features = ["serde"] }
maplit = "1.0.2"
percent-encoding = "2.1.0"
ruma-common = { version = "0.8.0", path = "../ruma-common", features = ["api", "events"] }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
serde = { version = "1.0.118", features = ["derive"] }
serde_json = "1.0.61"

View File

@ -19,7 +19,7 @@ pub mod request_registration_token_via_msisdn;
pub mod unbind_3pid;
pub mod whoami;
use ruma_serde::{Outgoing, StringEnum};
use ruma_common::serde::{Outgoing, StringEnum};
use serde::Serialize;
use crate::PrivOwnedStr;

View File

@ -32,7 +32,7 @@ pub mod v3 {
///
/// When false, the server can still take advantage of the soft logout method for the user's
/// remaining devices.
#[serde(default = "ruma_serde::default_true", skip_serializing_if = "ruma_serde::is_true")]
#[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")]
pub logout_devices: bool,
/// Additional authentication information for the user-interactive authentication API.

View File

@ -65,12 +65,12 @@ pub mod v3 {
///
/// Defaults to `User` if omitted.
#[ruma_api(query)]
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub kind: RegistrationKind,
/// If `true`, an `access_token` and `device_id` should not be returned
/// from this call, therefore preventing an automatic login.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub inhibit_login: bool,
/// Login `type` used by Appservices.

View File

@ -56,7 +56,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub submit_url: Option<String>,
}

View File

@ -59,7 +59,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub submit_url: Option<String>,
}

View File

@ -38,7 +38,7 @@ pub mod v3 {
pub matrix_server_name: Box<ServerName>,
/// Seconds until token expiration.
#[serde(with = "ruma_serde::duration::secs")]
#[serde(with = "ruma_common::serde::duration::secs")]
pub expires_in: Duration,
}

View File

@ -56,7 +56,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub submit_url: Option<String>,
}

View File

@ -51,7 +51,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub submit_url: Option<String>,
}

View File

@ -56,7 +56,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub submit_url: Option<String>,
}

View File

@ -59,7 +59,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub submit_url: Option<String>,
}

View File

@ -31,7 +31,7 @@ pub mod v3 {
pub device_id: Option<Box<DeviceId>>,
/// If `true`, the user is a guest user.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub is_guest: bool,
}

View File

@ -18,8 +18,10 @@ pub mod update_backup_version;
use std::collections::BTreeMap;
use js_int::UInt;
use ruma_common::{DeviceKeyId, UserId};
use ruma_serde::{Base64, Raw};
use ruma_common::{
serde::{Base64, Raw},
DeviceKeyId, UserId,
};
use serde::{Deserialize, Serialize};
/// A wrapper around a mapping of session IDs to key data.

View File

@ -8,8 +8,7 @@ pub mod v3 {
use std::collections::BTreeMap;
use js_int::UInt;
use ruma_common::{api::ruma_api, RoomId};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw, RoomId};
use crate::backup::KeyBackupData;

View File

@ -6,8 +6,7 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3room_keyskeysroomidsessionid
use js_int::UInt;
use ruma_common::{api::ruma_api, RoomId};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw, RoomId};
use crate::backup::KeyBackupData;

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3room_keysversion
use ruma_common::api::ruma_api;
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw};
use crate::backup::BackupAlgorithm;

View File

@ -8,8 +8,7 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3room_keysversionversion
use js_int::UInt;
use ruma_common::api::ruma_api;
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw};
use serde::{ser, Deserialize, Deserializer, Serialize};
use serde_json::value::{to_raw_value as to_raw_json_value, RawValue as RawJsonValue};

View File

@ -7,8 +7,7 @@ pub mod v3 {
use std::collections::BTreeMap;
use ruma_common::{api::ruma_api, RoomId};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw, RoomId};
use crate::backup::KeyBackupData;

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3room_keyskeysroomidsessionid
use ruma_common::{api::ruma_api, RoomId};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw, RoomId};
use crate::backup::KeyBackupData;

View File

@ -6,8 +6,7 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3room_keysversion
use js_int::UInt;
use ruma_common::api::ruma_api;
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw};
use serde::{ser, Deserialize, Deserializer, Serialize};
use serde_json::value::to_raw_value as to_raw_json_value;

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3room_keysversionversion
use ruma_common::api::ruma_api;
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, serde::Raw};
use crate::backup::BackupAlgorithm;

View File

@ -3,8 +3,7 @@
use std::{borrow::Cow, collections::BTreeMap};
use maplit::btreemap;
use ruma_common::RoomVersionId;
use ruma_serde::StringEnum;
use ruma_common::{serde::StringEnum, RoomVersionId};
use serde::{Deserialize, Serialize};
use serde_json::{from_value as from_json_value, to_value as to_json_value, Value as JsonValue};

View File

@ -5,8 +5,9 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3useruseridaccount_datatype
use ruma_common::{api::ruma_api, events::AnyGlobalAccountDataEventContent, UserId};
use ruma_serde::Raw;
use ruma_common::{
api::ruma_api, events::AnyGlobalAccountDataEventContent, serde::Raw, UserId,
};
ruma_api! {
metadata: {

View File

@ -5,8 +5,9 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3useruseridroomsroomidaccount_datatype
use ruma_common::{api::ruma_api, events::AnyRoomAccountDataEventContent, RoomId, UserId};
use ruma_serde::Raw;
use ruma_common::{
api::ruma_api, events::AnyRoomAccountDataEventContent, serde::Raw, RoomId, UserId,
};
ruma_api! {
metadata: {

View File

@ -8,9 +8,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyGlobalAccountDataEventContent, GlobalAccountDataEventContent},
serde::Raw,
UserId,
};
use ruma_serde::Raw;
use serde_json::value::to_raw_value as to_raw_json_value;
ruma_api! {

View File

@ -8,9 +8,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyRoomAccountDataEventContent, RoomAccountDataEventContent},
serde::Raw,
RoomId, UserId,
};
use ruma_serde::Raw;
use serde_json::value::to_raw_value as to_raw_json_value;
ruma_api! {

View File

@ -9,9 +9,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyRoomEvent, AnyStateEvent},
serde::Raw,
EventId, RoomId,
};
use ruma_serde::Raw;
use crate::filter::{IncomingRoomEventFilter, RoomEventFilter};
@ -46,7 +46,7 @@ pub mod v3 {
/// A RoomEventFilter to filter returned events with.
#[ruma_api(query)]
#[serde(
with = "ruma_serde::json_string",
with = "ruma_common::serde::json_string",
default,
skip_serializing_if = "RoomEventFilter::is_empty"
)]

View File

@ -46,7 +46,7 @@ pub mod v3 {
pub filter: Filter<'a>,
/// Network to fetch the public room lists from.
#[serde(flatten, skip_serializing_if = "ruma_serde::is_default")]
#[serde(flatten, skip_serializing_if = "ruma_common::serde::is_default")]
pub room_network: RoomNetwork<'a>,
}

View File

@ -262,7 +262,7 @@ impl OutgoingResponse for Error {
http::Response::builder()
.header(http::header::CONTENT_TYPE, "application/json")
.status(self.status_code)
.body(ruma_serde::json_to_buf(&ErrorBody::from(self))?)
.body(ruma_common::serde::json_to_buf(&ErrorBody::from(self))?)
.map_err(Into::into)
}
}

View File

@ -7,7 +7,7 @@ use std::{
};
use js_int::UInt;
use ruma_serde::{DeserializeFromCowStr, FromString};
use ruma_common::serde::{DeserializeFromCowStr, FromString};
use serde::{
de::{self, Deserialize, Deserializer, MapAccess, Visitor},
ser::{self, Serialize, SerializeMap, Serializer},

View File

@ -7,8 +7,10 @@ mod lazy_load;
mod url;
use js_int::UInt;
use ruma_common::{RoomId, UserId};
use ruma_serde::{Outgoing, StringEnum};
use ruma_common::{
serde::{Outgoing, StringEnum},
RoomId, UserId,
};
use serde::Serialize;
use crate::PrivOwnedStr;
@ -161,24 +163,24 @@ pub struct RoomFilter<'a> {
/// Include rooms that the user has left in the sync.
///
/// Defaults to `false`.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub include_leave: bool,
/// The per user account data to include for rooms.
#[serde(default, skip_serializing_if = "ruma_serde::is_empty")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
pub account_data: RoomEventFilter<'a>,
/// The message and state update events to include for rooms.
#[serde(default, skip_serializing_if = "ruma_serde::is_empty")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
pub timeline: RoomEventFilter<'a>,
/// The events that aren't recorded in the room history, e.g. typing and receipts, to include
/// for rooms.
#[serde(default, skip_serializing_if = "ruma_serde::is_empty")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
pub ephemeral: RoomEventFilter<'a>,
/// The state events to include for rooms.
#[serde(default, skip_serializing_if = "ruma_serde::is_empty")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
pub state: RoomEventFilter<'a>,
/// A list of room IDs to exclude.
@ -325,19 +327,19 @@ pub struct FilterDefinition<'a> {
///
/// 'client' will return the events in a format suitable for clients. 'federation' will return
/// the raw event as received over federation. The default is 'client'.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub event_format: EventFormat,
/// The presence updates to include.
#[serde(default, skip_serializing_if = "ruma_serde::is_empty")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
pub presence: Filter<'a>,
/// The user account data that isn't associated with rooms to include.
#[serde(default, skip_serializing_if = "ruma_serde::is_empty")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
pub account_data: Filter<'a>,
/// Filters to be applied to room data.
#[serde(default, skip_serializing_if = "ruma_serde::is_empty")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_empty")]
pub room: RoomFilter<'a>,
}
@ -382,7 +384,7 @@ impl IncomingFilterDefinition {
macro_rules! can_be_empty {
($ty:ident $(<$gen:tt>)?) => {
impl $(<$gen>)? ruma_serde::CanBeEmpty for $ty $(<$gen>)? {
impl $(<$gen>)? ruma_common::serde::CanBeEmpty for $ty $(<$gen>)? {
fn is_empty(&self) -> bool {
self.is_empty()
}

View File

@ -8,9 +8,9 @@ pub mod v3 {
use std::{collections::BTreeMap, time::Duration};
use ruma_common::{
api::ruma_api, encryption::OneTimeKey, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId,
api::ruma_api, encryption::OneTimeKey, serde::Raw, DeviceId, DeviceKeyAlgorithm,
DeviceKeyId, UserId,
};
use ruma_serde::Raw;
use serde_json::Value as JsonValue;
ruma_api! {
@ -29,7 +29,7 @@ pub mod v3 {
/// The time (in milliseconds) to wait when downloading keys from remote servers.
/// 10 seconds is the recommended default.
#[serde(
with = "ruma_serde::duration::opt_ms",
with = "ruma_common::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]

View File

@ -10,9 +10,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
encryption::{CrossSigningKey, DeviceKeys},
serde::Raw,
DeviceId, UserId,
};
use ruma_serde::Raw;
use serde_json::Value as JsonValue;
ruma_api! {
@ -33,7 +33,7 @@ pub mod v3 {
///
/// 10 seconds is the recommended default.
#[serde(
with = "ruma_serde::duration::opt_ms",
with = "ruma_common::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]

View File

@ -11,9 +11,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
encryption::{DeviceKeys, OneTimeKey},
serde::Raw,
DeviceKeyAlgorithm, DeviceKeyId,
};
use ruma_serde::Raw;
ruma_api! {
metadata: {

View File

@ -10,9 +10,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
encryption::{CrossSigningKey, DeviceKeys},
serde::{Raw, StringEnum},
DeviceId, UserId,
};
use ruma_serde::{Raw, StringEnum};
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3keysdevice_signingupload
use ruma_common::{api::ruma_api, encryption::CrossSigningKey};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, encryption::CrossSigningKey, serde::Raw};
use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse};

View File

@ -39,7 +39,7 @@ pub mod v3 {
/// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
#[ruma_api(query)]
#[cfg(feature = "unstable-msc2448")]
#[serde(default, skip_serializing_if = "ruma_serde::is_default", rename = "xyz.amorgan.blurhash")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default", rename = "xyz.amorgan.blurhash")]
pub generate_blurhash: bool,
}

View File

@ -32,7 +32,7 @@ pub mod v3 {
///
/// Used to prevent routing loops. Defaults to `true`.
#[ruma_api(query)]
#[serde(default = "ruma_serde::default_true", skip_serializing_if = "ruma_serde::is_true")]
#[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")]
pub allow_remote: bool,
}

View File

@ -36,7 +36,7 @@ pub mod v3 {
///
/// Used to prevent routing loops. Defaults to `true`.
#[ruma_api(query)]
#[serde(default = "ruma_serde::default_true", skip_serializing_if = "ruma_serde::is_true")]
#[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")]
pub allow_remote: bool,
}

View File

@ -6,8 +6,7 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixmediav3thumbnailservernamemediaid
use js_int::UInt;
use ruma_common::{api::ruma_api, Error, MxcUri, ServerName};
use ruma_serde::StringEnum;
use ruma_common::{api::ruma_api, serde::StringEnum, Error, MxcUri, ServerName};
use crate::PrivOwnedStr;
@ -53,7 +52,7 @@ pub mod v3 {
///
/// Used to prevent routing loops. Defaults to `true`.
#[ruma_api(query)]
#[serde(default = "ruma_serde::default_true", skip_serializing_if = "ruma_serde::is_true")]
#[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")]
pub allow_remote: bool,
}

View File

@ -14,8 +14,7 @@ pub mod unban_user;
use std::collections::BTreeMap;
use ruma_common::{thirdparty::Medium, ServerName, ServerSigningKeyId, UserId};
use ruma_serde::Outgoing;
use ruma_common::{serde::Outgoing, thirdparty::Medium, ServerName, ServerSigningKeyId, UserId};
use serde::Serialize;
/// A signature of an `m.third_party_invite` token to prove that this user owns a third party

View File

@ -5,8 +5,12 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidmembers
use ruma_common::{api::ruma_api, events::room::member::RoomMemberEvent, RoomId};
use ruma_serde::{Raw, StringEnum};
use ruma_common::{
api::ruma_api,
events::room::member::RoomMemberEvent,
serde::{Raw, StringEnum},
RoomId,
};
use crate::PrivOwnedStr;

View File

@ -10,8 +10,7 @@ pub mod v3 {
//! [spec-mxid]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidinvite
//! [spec-3pid]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3roomsroomidinvite-1
use ruma_common::{api::ruma_api, RoomId, UserId};
use ruma_serde::Outgoing;
use ruma_common::{api::ruma_api, serde::Outgoing, RoomId, UserId};
use serde::Serialize;
use crate::membership::{IncomingInvite3pid, Invite3pid};

View File

@ -66,7 +66,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,
}

View File

@ -9,9 +9,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyRoomEvent, AnyStateEvent},
serde::Raw,
RoomId,
};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
use crate::filter::{IncomingRoomEventFilter, RoomEventFilter};
@ -64,7 +64,7 @@ pub mod v3 {
/// A RoomEventFilter to filter returned events with.
#[ruma_api(query)]
#[serde(
with = "ruma_serde::json_string",
with = "ruma_common::serde::json_string",
default,
skip_serializing_if = "RoomEventFilter::is_empty"
)]

View File

@ -8,9 +8,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyMessageLikeEventContent, MessageLikeEventContent},
serde::Raw,
EventId, RoomId, TransactionId,
};
use ruma_serde::Raw;
use serde_json::value::to_raw_value as to_raw_json_value;
ruma_api! {

View File

@ -38,7 +38,7 @@ pub mod v3 {
/// The length of time in milliseconds since an action was performed by the user.
#[serde(
with = "ruma_serde::duration::opt_ms",
with = "ruma_common::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]

View File

@ -34,7 +34,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,

View File

@ -34,7 +34,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,

View File

@ -34,8 +34,8 @@ pub mod v3 {
feature = "compat",
serde(
default,
deserialize_with = "ruma_serde::empty_string_as_none",
serialize_with = "ruma_serde::none_as_empty_string"
deserialize_with = "ruma_common::serde::empty_string_as_none",
serialize_with = "ruma_common::serde::none_as_empty_string"
)
)]
#[cfg_attr(

View File

@ -1,11 +1,13 @@
//! Endpoints for push notifications.
use std::{convert::TryFrom, error::Error, fmt};
use ruma_common::push::{
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule, PatternedPushRuleInit,
PushCondition, PusherData, SimplePushRule, SimplePushRuleInit,
use ruma_common::{
push::{
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule,
PatternedPushRuleInit, PushCondition, PusherData, SimplePushRule, SimplePushRuleInit,
},
serde::StringEnum,
};
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::PrivOwnedStr;

View File

@ -7,9 +7,9 @@ pub mod v3 {
use js_int::UInt;
use ruma_common::{
api::ruma_api, events::AnySyncRoomEvent, push::Action, MilliSecondsSinceUnixEpoch, RoomId,
api::ruma_api, events::AnySyncRoomEvent, push::Action, serde::Raw,
MilliSecondsSinceUnixEpoch, RoomId,
};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
ruma_api! {

View File

@ -30,7 +30,7 @@ pub mod v3 {
/// Controls if another pusher with the same pushkey and app id should be created.
///
/// Defaults to `false`. See the spec for more details.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub append: bool,
}

View File

@ -6,7 +6,7 @@ pub mod get_room_event;
pub mod report_content;
pub mod upgrade_room;
use ruma_serde::StringEnum;
use ruma_common::serde::StringEnum;
use crate::PrivOwnedStr;

View File

@ -16,9 +16,9 @@ pub mod v3 {
AnyInitialStateEvent,
},
room::RoomType,
serde::{Raw, StringEnum},
RoomId, RoomName, RoomVersionId, UserId,
};
use ruma_serde::{Raw, StringEnum};
use serde::{Deserialize, Serialize};
use crate::{
@ -62,7 +62,7 @@ pub mod v3 {
pub invite_3pid: &'a [Invite3pid<'a>],
/// If set, this sets the `is_direct` flag on room invites.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub is_direct: bool,
/// If this is included, an `m.room.name` event will be sent into the room to indicate the
@ -97,7 +97,7 @@ pub mod v3 {
///
/// A private visibility will hide the room from the published room list. Defaults to
/// `Private`.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub visibility: Visibility,
}
@ -135,8 +135,8 @@ pub mod v3 {
/// Defaults to `true` if key does not exist.
#[serde(
rename = "m.federate",
default = "ruma_serde::default_true",
skip_serializing_if = "ruma_serde::is_true"
default = "ruma_common::serde::default_true",
skip_serializing_if = "ruma_common::serde::is_true"
)]
pub federate: bool,

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomideventeventid
use ruma_common::{api::ruma_api, events::AnyRoomEvent, EventId, RoomId};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, events::AnyRoomEvent, serde::Raw, EventId, RoomId};
ruma_api! {
metadata: {

View File

@ -11,9 +11,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyRoomEvent, AnyStateEvent},
serde::{Outgoing, Raw, StringEnum},
EventId, MxcUri, RoomId, UserId,
};
use ruma_serde::{Outgoing, Raw, StringEnum};
use serde::{Deserialize, Serialize};
use crate::{
@ -151,7 +151,7 @@ pub mod v3 {
/// Requests that the server returns the historic profile information for the users that
/// sent the events that were returned.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub include_profile: bool,
}
@ -484,7 +484,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,

View File

@ -7,8 +7,11 @@ pub mod v3 {
use std::borrow::Cow;
use ruma_common::{api::ruma_api, MxcUri};
use ruma_serde::{JsonObject, StringEnum};
use ruma_common::{
api::ruma_api,
serde::{JsonObject, StringEnum},
MxcUri,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue;
@ -249,7 +252,7 @@ pub mod v3 {
}
mod login_type_serde {
use ruma_serde::from_raw_json_value;
use ruma_common::serde::from_raw_json_value;
use serde::{de, Deserialize};
use serde_json::value::RawValue as RawJsonValue;

View File

@ -5,8 +5,11 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3login
use ruma_common::{api::ruma_api, DeviceId, ServerName, UserId};
use ruma_serde::{JsonObject, Outgoing};
use ruma_common::{
api::ruma_api,
serde::{JsonObject, Outgoing},
DeviceId, ServerName, UserId,
};
use serde::{
de::{self, DeserializeOwned},
Deserialize, Deserializer, Serialize,

View File

@ -3,9 +3,8 @@
use js_int::UInt;
use ruma_common::{
directory::PublicRoomJoinRule, events::space::child::HierarchySpaceChildStateEvent,
room::RoomType, MxcUri, RoomAliasId, RoomId, RoomName,
room::RoomType, serde::Raw, MxcUri, RoomAliasId, RoomId, RoomName,
};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};
pub mod get_hierarchy;
@ -21,7 +20,7 @@ pub struct SpaceHierarchyRoomsChunk {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub canonical_alias: Option<Box<RoomAliasId>>,
@ -54,12 +53,12 @@ pub struct SpaceHierarchyRoomsChunk {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,
/// The join rule of the room.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub join_rule: PublicRoomJoinRule,
/// The type of room from `m.room.create`, if any.

View File

@ -49,7 +49,7 @@ pub mod v1 {
///
/// Defaults to `false`.
#[ruma_api(query)]
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub suggested_only: bool,
}

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidstate
use ruma_common::{api::ruma_api, events::AnyStateEvent, RoomId};
use ruma_serde::Raw;
use ruma_common::{api::ruma_api, events::AnyStateEvent, serde::Raw, RoomId};
ruma_api! {
metadata: {

View File

@ -8,9 +8,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyStateEventContent, EventType},
serde::{Outgoing, Raw},
RoomId,
};
use ruma_serde::{Outgoing, Raw};
ruma_api! {
metadata: {
@ -70,7 +70,7 @@ pub mod v3 {
#[cfg(feature = "client")]
impl<'a> ruma_common::api::OutgoingRequest for Request<'a> {
type EndpointError = crate::Error;
type IncomingResponse = <Response as ruma_serde::Outgoing>::Incoming;
type IncomingResponse = <Response as ruma_common::serde::Outgoing>::Incoming;
const METADATA: ruma_common::api::Metadata = METADATA;

View File

@ -8,9 +8,9 @@ pub mod v3 {
use ruma_common::{
api::ruma_api,
events::{AnyStateEventContent, StateEventContent},
serde::{Outgoing, Raw},
EventId, RoomId,
};
use ruma_serde::{Outgoing, Raw};
use serde_json::value::to_raw_value as to_raw_json_value;
ruma_api! {
@ -147,7 +147,7 @@ pub mod v3 {
.ok_or(ruma_common::api::error::IntoHttpError::NeedsAuthentication)?
))?,
)
.body(ruma_serde::json_to_buf(&self.body)?)?;
.body(ruma_common::serde::json_to_buf(&self.body)?)?;
Ok(http_request)
}

View File

@ -16,9 +16,9 @@ pub mod v3 {
AnyToDeviceEvent,
},
presence::PresenceState,
serde::{Outgoing, Raw},
DeviceKeyAlgorithm, RoomId, UserId,
};
use ruma_serde::{Outgoing, Raw};
use serde::{Deserialize, Serialize};
use crate::filter::{FilterDefinition, IncomingFilterDefinition};
@ -51,20 +51,20 @@ pub mod v3 {
pub since: Option<&'a str>,
/// Controls whether to include the full state for all rooms the user is a member of.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
#[ruma_api(query)]
pub full_state: bool,
/// Controls whether the client is automatically marked as online by polling this API.
///
/// Defaults to `PresenceState::Online`.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
#[ruma_api(query)]
pub set_presence: &'a PresenceState,
/// The maximum time to poll in milliseconds before returning this request.
#[serde(
with = "ruma_serde::duration::opt_ms",
with = "ruma_common::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none",
)]
@ -154,7 +154,7 @@ pub mod v3 {
// functionally equivalent to looking at whether the first symbol is a '{' as the spec
// says. (there are probably some corner cases like leading whitespace)
/// A complete filter definition serialized to JSON.
#[serde(with = "ruma_serde::json_string")]
#[serde(with = "ruma_common::serde::json_string")]
FilterDefinition(FilterDefinition<'a>),
/// The ID of a filter saved on the server.
@ -334,7 +334,7 @@ pub mod v3 {
/// True if the number of events returned was limited by the `limit` on the filter.
///
/// Default to `false`.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub limited: bool,
/// A token that can be supplied to to the `from` parameter of the

View File

@ -8,10 +8,9 @@ pub mod v3 {
use std::collections::BTreeMap;
use ruma_common::{
api::ruma_api, events::AnyToDeviceEventContent, to_device::DeviceIdOrAllDevices,
TransactionId, UserId,
api::ruma_api, events::AnyToDeviceEventContent, serde::Raw,
to_device::DeviceIdOrAllDevices, TransactionId, UserId,
};
use ruma_serde::Raw;
ruma_api! {
metadata: {

View File

@ -73,7 +73,7 @@ pub mod v3 {
typing: bool,
#[serde(
with = "ruma_serde::duration::opt_ms",
with = "ruma_common::serde::duration::opt_ms",
default,
skip_serializing_if = "Option::is_none"
)]

View File

@ -10,10 +10,10 @@ use ruma_common::{
error::{DeserializationError, IntoHttpError},
EndpointError, OutgoingResponse,
},
serde::{from_raw_json_value, JsonObject, Outgoing, StringEnum},
thirdparty::Medium,
ClientSecret, SessionId,
};
use ruma_serde::{from_raw_json_value, JsonObject, Outgoing, StringEnum};
use serde::{
de::{self, DeserializeOwned},
Deserialize, Deserializer, Serialize,
@ -734,7 +734,7 @@ impl OutgoingResponse for UiaaResponse {
UiaaResponse::AuthResponse(authentication_info) => http::Response::builder()
.header(http::header::CONTENT_TYPE, "application/json")
.status(&http::StatusCode::UNAUTHORIZED)
.body(ruma_serde::json_to_buf(&authentication_info)?)
.body(ruma_common::serde::json_to_buf(&authentication_info)?)
.map_err(Into::into),
UiaaResponse::MatrixError(error) => error.try_into_http_response(),
}

View File

@ -1,8 +1,7 @@
//! Helper module for the Serialize / Deserialize impl's for the User struct
//! in the parent module.
use ruma_common::thirdparty::Medium;
use ruma_serde::Outgoing;
use ruma_common::{serde::Outgoing, thirdparty::Medium};
use serde::Serialize;
// The following structs could just be used in place of the one in the parent module, but

View File

@ -91,7 +91,7 @@ pub mod v3 {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,
}

View File

@ -35,7 +35,7 @@ pub mod v3 {
pub uris: Vec<String>,
/// The time-to-live in seconds.
#[serde(with = "ruma_serde::duration::secs")]
#[serde(with = "ruma_common::serde::duration::secs")]
pub ttl: Duration,
}

View File

@ -43,7 +43,6 @@ isahc-crate = { package = "isahc", version = "1.3.1", optional = true }
reqwest = { version = "0.11.4", optional = true, default-features = false }
ruma-client-api = { version = "0.13.0", path = "../ruma-client-api", optional = true, features = ["client"] }
ruma-common = { version = "0.8.0", path = "../ruma-common", features = ["api"] }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
serde = { version = "1.0.118", features = ["derive"] }
serde_json = "1.0.61"
tracing = { version = "0.1.30", default-features = false, features = ["std"] }

View File

@ -189,7 +189,7 @@ fn add_user_id_to_query<C: HttpClient + ?Sized, R: OutgoingRequest>(
) -> impl FnOnce(&mut http::Request<C::RequestBody>) -> Result<(), ResponseError<C, R>> + '_ {
use assign::assign;
use http::uri::Uri;
use ruma_serde::urlencoded;
use ruma_common::serde::urlencoded;
move |http_request| {
let extra_params = urlencoded::to_string(&[("user_id", user_id)]).unwrap();

View File

@ -20,7 +20,7 @@ default = ["client", "server"]
client = []
server = []
api = ["bytes", "http", "thiserror"]
api = ["http", "thiserror"]
compat = ["ruma-macros/compat", "ruma-identifiers-validation/compat"]
events = ["indoc", "thiserror"]
markdown = ["pulldown-cmark"]
@ -36,19 +36,21 @@ unstable-msc2677 = []
unstable-msc3551 = ["unstable-msc1767"]
[dependencies]
bytes = { version = "1.0.1", optional = true }
base64 = "0.13.0"
bytes = "1.0.1"
criterion = { version = "0.3.3", optional = true }
either = { version = "1.6.1", optional = true }
form_urlencoded = "1.0.0"
http = { version = "0.2.2", optional = true }
indexmap = { version = "1.6.2", features = ["serde-1"] }
indoc = { version = "1.0", optional = true }
itoa = "1.0.1"
js_int = { version = "0.2.0", features = ["serde"] }
percent-encoding = "2.1.0"
pulldown-cmark = { version = "0.8", default-features = false, optional = true }
rand_crate = { package = "rand", version = "0.8.3", optional = true }
ruma-identifiers-validation = { version = "0.7.0", path = "../ruma-identifiers-validation", default-features = false }
ruma-macros = { version = "=0.1.0", path = "../ruma-macros" }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
serde = { version = "1.0.118", features = ["derive"] }
serde_json = { version = "1.0.64", features = ["raw_value"] }
thiserror = { version = "1.0.26", optional = true }
@ -59,11 +61,9 @@ wildmatch = "2.0.0"
[dev-dependencies]
assign = "1.1.1"
bytes = "1.0.1"
http = "0.2.2"
maplit = "1.0.2"
matches = "0.1.8"
ruma-macros = { version = "=0.1.0", path = "../ruma-macros" }
trybuild = "1.0.42"
[[bench]]

View File

@ -9,10 +9,12 @@
#[cfg(feature = "criterion")]
use criterion::{criterion_group, criterion_main, Criterion};
use ruma_common::events::{
room::power_levels::RoomPowerLevelsEventContent, AnyRoomEvent, AnyStateEvent, StateEvent,
use ruma_common::{
events::{
room::power_levels::RoomPowerLevelsEventContent, AnyRoomEvent, AnyStateEvent, StateEvent,
},
serde::Raw,
};
use ruma_serde::Raw;
use serde_json::json;
fn power_levels() -> serde_json::Value {

View File

@ -301,7 +301,7 @@ pub trait OutgoingRequestAppserviceExt: OutgoingRequest {
) -> Result<http::Request<T>, IntoHttpError> {
let mut http_request =
self.try_into_http_request(base_url, access_token, considering_versions)?;
let user_id_query = ruma_serde::urlencoded::to_string(&[("user_id", user_id)])?;
let user_id_query = crate::serde::urlencoded::to_string(&[("user_id", user_id)])?;
let uri = http_request.uri().to_owned();
let mut parts = uri.into_parts();

View File

@ -39,7 +39,7 @@ impl OutgoingResponse for MatrixError {
http::Response::builder()
.header(http::header::CONTENT_TYPE, "application/json")
.status(self.status_code)
.body(ruma_serde::json_to_buf(&self.body)?)
.body(crate::serde::json_to_buf(&self.body)?)
.map_err(Into::into)
}
}
@ -85,7 +85,7 @@ pub enum IntoHttpError {
/// Query parameter serialization failed.
#[error("Query parameter serialization failed: {0}")]
Query(#[from] ruma_serde::urlencoded::ser::Error),
Query(#[from] crate::serde::urlencoded::ser::Error),
/// Header serialization failed.
#[error("Header serialization failed: {0}")]
@ -198,7 +198,7 @@ pub enum DeserializationError {
/// Query parameter deserialization failed.
#[error("{0}")]
Query(#[from] ruma_serde::urlencoded::de::Error),
Query(#[from] crate::serde::urlencoded::de::Error),
/// Got an invalid identifier.
#[error("{0}")]

View File

@ -1,8 +1,6 @@
//! Common types for authentication.
use ruma_serde::StringEnum;
use crate::PrivOwnedStr;
use crate::{serde::StringEnum, PrivOwnedStr};
/// Access token types.
///

View File

@ -2,8 +2,8 @@
use std::fmt;
use crate::serde::{Outgoing, StringEnum};
use js_int::UInt;
use ruma_serde::{Outgoing, StringEnum};
use serde::{
de::{Error, MapAccess, Visitor},
ser::SerializeStruct,
@ -24,7 +24,7 @@ pub struct PublicRoomsChunk {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "crate::serde::empty_string_as_none")
)]
pub canonical_alias: Option<Box<RoomAliasId>>,
@ -57,12 +57,12 @@ pub struct PublicRoomsChunk {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "crate::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,
/// The join rule of the room.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "crate::serde::is_default")]
pub join_rule: PublicRoomJoinRule,
}

View File

@ -4,10 +4,9 @@
use std::collections::BTreeMap;
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
use crate::{DeviceId, DeviceKeyId, EventEncryptionAlgorithm, UserId};
use crate::{serde::Base64, DeviceId, DeviceKeyId, EventEncryptionAlgorithm, UserId};
/// Identity keys for a device.
#[derive(Clone, Debug, Deserialize, Serialize)]
@ -87,7 +86,7 @@ pub struct SignedKey {
pub signatures: SignedKeySignatures,
/// Is this key considered to be a fallback key, defaults to false.
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[serde(default, skip_serializing_if = "crate::serde::is_default")]
pub fallback: bool,
}

View File

@ -126,12 +126,11 @@
//! type alias), allowing content to be converted to and from JSON independently of the surrounding
//! event structure, if needed.
use ruma_serde::Raw;
use serde::{de::IgnoredAny, Deserialize, Serialize, Serializer};
use serde_json::value::RawValue as RawJsonValue;
use self::room::redaction::SyncRoomRedactionEvent;
use crate::{EventEncryptionAlgorithm, RoomVersionId};
use crate::{serde::Raw, EventEncryptionAlgorithm, RoomVersionId};
// Needs to be public for trybuild tests
#[doc(hidden)]
@ -227,7 +226,7 @@ pub trait RedactContent {
fn redact(self, version: &RoomVersionId) -> Self::Redacted;
}
/// Extension trait for [`Raw<_>`][ruma_serde::Raw].
/// Extension trait for [`Raw<_>`][crate::serde::Raw].
pub trait RawExt<T: EventContent> {
/// Try to deserialize the JSON as an event's content.
fn deserialize_content(&self, event_type: &str) -> serde_json::Result<T>;

View File

@ -2,10 +2,9 @@
//!
//! This module also contains types shared by events in its child namespaces.
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::PrivOwnedStr;
use crate::{serde::StringEnum, PrivOwnedStr};
pub mod answer;
pub mod candidates;

View File

@ -4,10 +4,9 @@
use js_int::UInt;
use ruma_macros::EventContent;
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::PrivOwnedStr;
use crate::{serde::StringEnum, PrivOwnedStr};
/// The content of an `m.call.hangup` event.
///

View File

@ -1,5 +1,4 @@
use ruma_macros::{event_enum, EventEnumFromEvent};
use ruma_serde::from_raw_json_value;
use serde::{de, Deserialize};
use serde_json::value::RawValue as RawJsonValue;
@ -8,7 +7,9 @@ use super::{
room::{encrypted, redaction::SyncRoomRedactionEvent},
Redact, UnsignedDeHelper,
};
use crate::{EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, UserId};
use crate::{
serde::from_raw_json_value, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, UserId,
};
event_enum! {
/// Any global account data event.

View File

@ -6,14 +6,13 @@ use std::collections::BTreeMap;
use js_int::UInt;
use ruma_macros::EventContent;
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
use super::{
message::MessageContent,
room::{message::Relation, JsonWebKey},
};
use crate::MxcUri;
use crate::{serde::Base64, MxcUri};
/// The encryption info of a file sent to a room with end-to-end encryption enabled.
///

View File

@ -15,7 +15,7 @@ use crate::UserId;
#[ruma_event(type = "m.ignored_user_list", kind = GlobalAccountData)]
pub struct IgnoredUserListEventContent {
/// A list of users to ignore.
#[serde(with = "ruma_serde::vec_as_map_of_empty")]
#[serde(with = "crate::serde::vec_as_map_of_empty")]
pub ignored_users: Vec<Box<UserId>>,
}

View File

@ -7,10 +7,9 @@
//!
//! [MSC2241]: https://github.com/matrix-org/matrix-spec-proposals/pull/2241
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::{EventId, PrivOwnedStr};
use crate::{serde::StringEnum, EventId, PrivOwnedStr};
pub mod accept;
pub mod cancel;

View File

@ -5,7 +5,6 @@
use std::collections::BTreeMap;
use ruma_macros::EventContent;
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
@ -13,7 +12,7 @@ use super::{
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, Relation,
ShortAuthenticationString,
};
use crate::TransactionId;
use crate::{serde::Base64, TransactionId};
/// The content of a to-device `m.key.verification.accept` event.
///
@ -165,9 +164,8 @@ impl From<SasV1ContentInit> for SasV1Content {
mod tests {
use std::collections::BTreeMap;
use crate::{event_id, user_id};
use crate::{event_id, serde::Base64, user_id};
use matches::assert_matches;
use ruma_serde::Base64;
use serde_json::{
from_value as from_json_value, json, to_value as to_json_value, Value as JsonValue,
};

View File

@ -3,11 +3,10 @@
//! [`m.key.verification.cancel`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationcancel
use ruma_macros::EventContent;
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use super::Relation;
use crate::{PrivOwnedStr, TransactionId};
use crate::{serde::StringEnum, PrivOwnedStr, TransactionId};
/// The content of a to-device `m.key.verification.cancel` event.
///

View File

@ -3,11 +3,10 @@
//! [`m.key.verification.key`]: https://spec.matrix.org/v1.2/client-server-api/#mkeyverificationkey
use ruma_macros::EventContent;
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
use super::Relation;
use crate::TransactionId;
use crate::{serde::Base64, TransactionId};
/// The content of a to-device `m.key.verification.key` event.
///

View File

@ -5,11 +5,10 @@
use std::collections::BTreeMap;
use ruma_macros::EventContent;
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
use super::Relation;
use crate::TransactionId;
use crate::{serde::Base64, TransactionId};
/// The content of a to-device `m.key.verification.` event.
///

View File

@ -5,7 +5,6 @@
use std::collections::BTreeMap;
use ruma_macros::EventContent;
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
@ -13,7 +12,7 @@ use super::{
HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, Relation,
ShortAuthenticationString,
};
use crate::{DeviceId, TransactionId};
use crate::{serde::Base64, DeviceId, TransactionId};
/// The content of a to-device `m.key.verification.start` event.
///
@ -200,9 +199,8 @@ impl From<SasV1ContentInit> for SasV1Content {
mod tests {
use std::collections::BTreeMap;
use crate::{event_id, user_id};
use crate::{event_id, serde::Base64, user_id};
use matches::assert_matches;
use ruma_serde::Base64;
use serde_json::{
from_value as from_json_value, json, to_value as to_json_value, Value as JsonValue,
};

View File

@ -1,9 +1,8 @@
//! Modules and types for events in the `m.policy.rule` namespace.
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::PrivOwnedStr;
use crate::{serde::StringEnum, PrivOwnedStr};
pub mod room;
pub mod server;

View File

@ -20,7 +20,6 @@ mod tests {
use std::convert::TryInto;
use js_int::int;
use ruma_serde::Raw;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{PolicyRuleRoomEvent, PolicyRuleRoomEventContent};
@ -30,7 +29,9 @@ mod tests {
policy::rule::{PolicyRuleEventContent, Recommendation},
Unsigned,
},
room_id, user_id, MilliSecondsSinceUnixEpoch,
room_id,
serde::Raw,
user_id, MilliSecondsSinceUnixEpoch,
};
#[test]

View File

@ -34,7 +34,7 @@ pub struct PresenceEventContent {
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(
feature = "compat",
serde(default, deserialize_with = "ruma_serde::empty_string_as_none")
serde(default, deserialize_with = "crate::serde::empty_string_as_none")
)]
pub avatar_url: Option<Box<MxcUri>>,

View File

@ -5,10 +5,12 @@
use std::collections::BTreeMap;
use js_int::UInt;
use ruma_serde::{base64::UrlSafe, Base64};
use serde::{Deserialize, Serialize};
use crate::MxcUri;
use crate::{
serde::{base64::UrlSafe, Base64},
MxcUri,
};
pub mod aliases;
pub mod avatar;

View File

@ -20,7 +20,7 @@ pub struct RoomCanonicalAliasEventContent {
/// with no canonical alias.
#[serde(
default,
deserialize_with = "ruma_serde::empty_string_as_none",
deserialize_with = "crate::serde::empty_string_as_none",
skip_serializing_if = "Option::is_none"
)]
pub alias: Option<Box<RoomAliasId>>,

View File

@ -25,8 +25,8 @@ pub struct RoomCreateEventContent {
/// Whether or not this room's data should be transferred to other homeservers.
#[serde(
rename = "m.federate",
default = "ruma_serde::default_true",
skip_serializing_if = "ruma_serde::is_true"
default = "crate::serde::default_true",
skip_serializing_if = "crate::serde::is_true"
)]
pub federate: bool,

Some files were not shown because too many files have changed in this diff Show More