common: Merge ruma-events into ruma-common

This commit is contained in:
Kévin Commaille 2022-03-04 12:45:07 +01:00 committed by GitHub
parent 588fe9c006
commit c3f9a3cb70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
172 changed files with 416 additions and 945 deletions

View File

@ -103,7 +103,7 @@ should generally be implemented by creating or using a more constrained type tha
that field for example, we have a number of identifier types but the Matrix spec uses `string` for
fields that hold user IDs / room IDs and so on.
Almost all types in `ruma-events` and the API crates use the `#[non_exhaustive]` attribute, to allow
Almost all types in `ruma-common` and the API crates use the `#[non_exhaustive]` attribute, to allow
us to adapt to new minor releases of the Matrix specification without having a major release of our
crates. You can generally just apply `#[non_exhaustive]` to everything it's a backwards compatible
change to remove it in the rare case it is not warranted.

View File

@ -21,8 +21,7 @@ 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"] }
ruma-events = { version = "0.26.0", path = "../ruma-events" }
ruma-common = { version = "0.8.0", path = "../ruma-common", features = ["api", "events"] }
ruma-identifiers = { version = "0.22.0", path = "../ruma-identifiers" }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
serde = { version = "1.0.118", features = ["derive"] }

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;
use ruma_events::AnyRoomEvent;
use ruma_common::{api::ruma_api, events::AnyRoomEvent};
use ruma_identifiers::TransactionId;
use ruma_serde::Raw;

View File

@ -28,8 +28,7 @@ http = "0.2.2"
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"] }
ruma-events = { version = "0.26.0", path = "../ruma-events" }
ruma-common = { version = "0.8.0", path = "../ruma-common", features = ["api", "events"] }
ruma-identifiers = { version = "0.22.0", path = "../ruma-identifiers" }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
serde = { version = "1.0.118", features = ["derive"] }

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3useruseridaccount_datatype
use ruma_common::api::ruma_api;
use ruma_events::AnyGlobalAccountDataEventContent;
use ruma_common::{api::ruma_api, events::AnyGlobalAccountDataEventContent};
use ruma_identifiers::UserId;
use ruma_serde::Raw;
@ -35,7 +34,7 @@ pub mod v3 {
response: {
/// Account data content for the given type.
///
/// Use `ruma_events::RawExt` for deserialization.
/// Use `ruma_common::events::RawExt` for deserialization.
#[ruma_api(body)]
pub account_data: Raw<AnyGlobalAccountDataEventContent>,
}

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3useruseridroomsroomidaccount_datatype
use ruma_common::api::ruma_api;
use ruma_events::AnyRoomAccountDataEventContent;
use ruma_common::{api::ruma_api, events::AnyRoomAccountDataEventContent};
use ruma_identifiers::{RoomId, UserId};
use ruma_serde::Raw;
@ -39,7 +38,7 @@ pub mod v3 {
response: {
/// Account data content for the given type.
///
/// Use `ruma_events::RawExt` for deserialization.
/// Use `ruma_common::events::RawExt` for deserialization.
#[ruma_api(body)]
pub account_data: Raw<AnyRoomAccountDataEventContent>,
}

View File

@ -5,8 +5,10 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3useruseridaccount_datatype
use ruma_common::api::ruma_api;
use ruma_events::{AnyGlobalAccountDataEventContent, GlobalAccountDataEventContent};
use ruma_common::{
api::ruma_api,
events::{AnyGlobalAccountDataEventContent, GlobalAccountDataEventContent},
};
use ruma_identifiers::UserId;
use ruma_serde::Raw;
use serde_json::value::to_raw_value as to_raw_json_value;

View File

@ -5,8 +5,10 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3useruseridroomsroomidaccount_datatype
use ruma_common::api::ruma_api;
use ruma_events::{AnyRoomAccountDataEventContent, RoomAccountDataEventContent};
use ruma_common::{
api::ruma_api,
events::{AnyRoomAccountDataEventContent, RoomAccountDataEventContent},
};
use ruma_identifiers::{RoomId, UserId};
use ruma_serde::Raw;
use serde_json::value::to_raw_value as to_raw_json_value;

View File

@ -6,8 +6,10 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidcontexteventid
use js_int::{uint, UInt};
use ruma_common::api::ruma_api;
use ruma_events::{AnyRoomEvent, AnyStateEvent};
use ruma_common::{
api::ruma_api,
events::{AnyRoomEvent, AnyStateEvent},
};
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;

View File

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

View File

@ -6,8 +6,10 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidmessages
use js_int::{uint, UInt};
use ruma_common::api::ruma_api;
use ruma_events::{AnyRoomEvent, AnyStateEvent};
use ruma_common::{
api::ruma_api,
events::{AnyRoomEvent, AnyStateEvent},
};
use ruma_identifiers::RoomId;
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};

View File

@ -5,8 +5,10 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid
use ruma_common::api::ruma_api;
use ruma_events::{AnyMessageLikeEventContent, MessageLikeEventContent};
use ruma_common::{
api::ruma_api,
events::{AnyMessageLikeEventContent, MessageLikeEventContent},
};
use ruma_identifiers::{EventId, RoomId, TransactionId};
use ruma_serde::Raw;
use serde_json::value::to_raw_value as to_raw_json_value;

View File

@ -6,8 +6,9 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3notifications
use js_int::UInt;
use ruma_common::{api::ruma_api, push::Action, MilliSecondsSinceUnixEpoch};
use ruma_events::AnySyncRoomEvent;
use ruma_common::{
api::ruma_api, events::AnySyncRoomEvent, push::Action, MilliSecondsSinceUnixEpoch,
};
use ruma_identifiers::RoomId;
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};

View File

@ -6,13 +6,16 @@ pub mod v3 {
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3createroom
use assign::assign;
use ruma_common::{api::ruma_api, room::RoomType};
use ruma_events::{
room::{
create::{PreviousRoom, RoomCreateEventContent},
power_levels::RoomPowerLevelsEventContent,
use ruma_common::{
api::ruma_api,
events::{
room::{
create::{PreviousRoom, RoomCreateEventContent},
power_levels::RoomPowerLevelsEventContent,
},
AnyInitialStateEvent,
},
AnyInitialStateEvent,
room::RoomType,
};
use ruma_identifiers::{RoomId, RoomName, RoomVersionId, UserId};
use ruma_serde::{Raw, StringEnum};

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;
use ruma_events::AnyRoomEvent;
use ruma_common::{api::ruma_api, events::AnyRoomEvent};
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::Raw;

View File

@ -8,8 +8,10 @@ pub mod v3 {
use std::collections::BTreeMap;
use js_int::{uint, UInt};
use ruma_common::api::ruma_api;
use ruma_events::{AnyRoomEvent, AnyStateEvent};
use ruma_common::{
api::ruma_api,
events::{AnyRoomEvent, AnyStateEvent},
};
use ruma_identifiers::{EventId, MxcUri, RoomId, UserId};
use ruma_serde::{Outgoing, Raw, StringEnum};
use serde::{Deserialize, Serialize};

View File

@ -1,8 +1,10 @@
//! Endpoints for spaces.
use js_int::UInt;
use ruma_common::{directory::PublicRoomJoinRule, room::RoomType};
use ruma_events::space::child::HierarchySpaceChildStateEvent;
use ruma_common::{
directory::PublicRoomJoinRule, events::space::child::HierarchySpaceChildStateEvent,
room::RoomType,
};
use ruma_identifiers::{MxcUri, RoomAliasId, RoomId, RoomName};
use ruma_serde::Raw;
use serde::{Deserialize, Serialize};

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;
use ruma_events::AnyStateEvent;
use ruma_common::{api::ruma_api, events::AnyStateEvent};
use ruma_identifiers::RoomId;
use ruma_serde::Raw;

View File

@ -5,8 +5,10 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3roomsroomidstateeventtypestatekey
use ruma_common::api::ruma_api;
use ruma_events::{AnyStateEventContent, EventType};
use ruma_common::{
api::ruma_api,
events::{AnyStateEventContent, EventType},
};
use ruma_identifiers::RoomId;
use ruma_serde::{Outgoing, Raw};
@ -26,7 +28,7 @@ pub mod v3 {
/// The content of the state event.
///
/// Since the inner type of the `Raw` does not implement `Deserialize`, you need to use
/// `ruma_events::RawExt` to deserialize it.
/// `ruma_common::events::RawExt` to deserialize it.
#[ruma_api(body)]
pub content: Raw<AnyStateEventContent>,
}

View File

@ -5,8 +5,10 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey
use ruma_common::api::ruma_api;
use ruma_events::{AnyStateEventContent, StateEventContent};
use ruma_common::{
api::ruma_api,
events::{AnyStateEventContent, StateEventContent},
};
use ruma_identifiers::{EventId, RoomId};
use ruma_serde::{Outgoing, Raw};
use serde_json::value::to_raw_value as to_raw_json_value;

View File

@ -8,11 +8,14 @@ pub mod v3 {
use std::{collections::BTreeMap, time::Duration};
use js_int::UInt;
use ruma_common::{api::ruma_api, presence::PresenceState};
use ruma_events::{
presence::PresenceEvent, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent,
AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, AnySyncStateEvent,
AnyToDeviceEvent,
use ruma_common::{
api::ruma_api,
events::{
presence::PresenceEvent, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent,
AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, AnySyncStateEvent,
AnyToDeviceEvent,
},
presence::PresenceState,
};
use ruma_identifiers::{DeviceKeyAlgorithm, RoomId, UserId};
use ruma_serde::{Outgoing, Raw};

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#put_matrixclientv3useruseridroomsroomidtagstag
use ruma_common::api::ruma_api;
use ruma_events::tag::TagInfo;
use ruma_common::{api::ruma_api, events::tag::TagInfo};
use ruma_identifiers::{RoomId, UserId};
ruma_api! {

View File

@ -5,8 +5,7 @@ pub mod v3 {
//!
//! [spec]: https://spec.matrix.org/v1.2/client-server-api/#get_matrixclientv3useruseridroomsroomidtags
use ruma_common::api::ruma_api;
use ruma_events::tag::Tags;
use ruma_common::{api::ruma_api, events::tag::Tags};
use ruma_identifiers::{RoomId, UserId};
ruma_api! {
@ -56,8 +55,10 @@ pub mod v3 {
#[cfg(all(test, feature = "server"))]
mod server_tests {
use assign::assign;
use ruma_common::api::OutgoingResponse;
use ruma_events::tag::{TagInfo, Tags};
use ruma_common::{
api::OutgoingResponse,
events::tag::{TagInfo, Tags},
};
use serde_json::json;
use super::Response;

View File

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

View File

@ -21,17 +21,28 @@ client = []
server = []
api = ["bytes", "http", "percent-encoding", "ruma-macros", "thiserror"]
compat = []
compat = ["ruma-macros/compat"]
events = ["indoc", "ruma-macros", "ruma-identifiers/serde", "thiserror"]
markdown = ["pulldown-cmark"]
unstable-exhaustive-types = []
unstable-pdu = []
unstable-pre-spec = []
unstable-msc1767 = []
unstable-msc2448 = []
unstable-msc2675 = []
unstable-msc2676 = []
unstable-msc2677 = []
unstable-msc3551 = ["unstable-msc1767"]
[dependencies]
bytes = { version = "1.0.1", optional = true }
criterion = { version = "0.3.3", optional = true }
http = { version = "0.2.2", optional = true }
indexmap = { version = "1.6.2", features = ["serde-1"] }
indoc = { version = "1.0", optional = true }
js_int = { version = "0.2.0", features = ["serde"] }
percent-encoding = { version = "2.1.0", optional = true }
pulldown-cmark = { version = "0.8", default-features = false, optional = true }
ruma-identifiers = { version = "0.22.0", path = "../ruma-identifiers" }
ruma-macros = { version = "=0.1.0", path = "../ruma-macros", optional = true }
ruma-serde = { version = "0.6.0", path = "../ruma-serde" }
@ -42,9 +53,15 @@ tracing = "0.1.25"
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-events = { version = "0.26.0", path = "../ruma-events" }
ruma-identifiers = { version = "0.22.0", path = "../ruma-identifiers", features = ["rand", "serde"] }
ruma-macros = { version = "=0.1.0", path = "../ruma-macros" }
trybuild = "1.0.38"
[[bench]]
name = "event_deserialize"
harness = false

View File

@ -13,3 +13,8 @@ The feature-gated modules are defined as follow:
Behind the `api` feature, core types used to define the requests and responses for each endpoint in
the various [Matrix](https://matrix.org/) API specifications. These types can be shared by client
and server code for all Matrix APIs.
### `events` module
Behind the `events` feature, serializable types for the events in the [Matrix](https://matrix.org/)
specification that can be shared by client and server code.

View File

@ -4,11 +4,12 @@
// To pass args to criterion, use this form
// `cargo bench --features criterion --bench <name of the bench> -- --save-baseline <name>`.
#![cfg(feature = "events")]
#![allow(unused_imports, dead_code)]
#[cfg(feature = "criterion")]
use criterion::{criterion_group, criterion_main, Criterion};
use ruma_events::{
use ruma_common::events::{
room::power_levels::RoomPowerLevelsEventContent, AnyRoomEvent, AnyStateEvent, StateEvent,
};
use ruma_serde::Raw;

View File

@ -1,7 +1,5 @@
#![doc(html_favicon_url = "https://www.ruma.io/favicon.ico")]
#![doc(html_logo_url = "https://www.ruma.io/images/logo.png")]
//! (De)serializable types for the events in the [Matrix](https://matrix.org) specification.
//! These types are used by other ruma crates.
//! These types are used by other Ruma crates.
//!
//! All data exchanged over Matrix is expressed as an event.
//! Different event types represent different actions, such as joining a room or sending a message.
@ -9,12 +7,12 @@
//! While anyone can create a new event type for their own purposes, the Matrix specification
//! defines a number of event types which are considered core to the protocol, and Matrix clients
//! and servers must understand their semantics.
//! ruma-events contains Rust types for each of the event types defined by the specification and
//! This module contains Rust types for each of the event types defined by the specification and
//! facilities for extending the event system for custom event types.
//!
//! # Event types
//!
//! ruma-events includes a Rust enum called `EventType`, which provides a simple enumeration of
//! This module includes a Rust enum called [`EventType`], which provides a simple enumeration of
//! all the event types defined by the Matrix specification. Matrix event types are serialized to
//! JSON strings in [reverse domain name
//! notation](https://en.wikipedia.org/wiki/Reverse_domain_name_notation), although the core event
@ -22,20 +20,21 @@
//!
//! # Core event types
//!
//! ruma-events includes Rust types for every one of the event types in the Matrix specification.
//! This module includes Rust types for every one of the event types in the Matrix specification.
//! To better organize the crate, these types live in separate modules with a hierarchy that
//! matches the reverse domain name notation of the event type.
//! For example, the `m.room.message` event lives at `ruma_events::room::message::MessageLikeEvent`.
//! Each type's module also contains a Rust type for that event type's `content` field, and any
//! other supporting types required by the event's other fields.
//! For example, the `m.room.message` event lives at
//! `ruma_common::events::::room::message::MessageLikeEvent`. Each type's module also contains a
//! Rust type for that event type's `content` field, and any other supporting types required by the
//! event's other fields.
//!
//! # Extending Ruma with custom events
//!
//! For our examples we will start with a simple custom state event. `ruma_event`
//! specifies the state event's `type` and it's [`kind`](crate::EventKind).
//! specifies the state event's `type` and it's [`kind`](EventKind).
//!
//! ```rust
//! use ruma_events::macros::EventContent;
//! use ruma_common::events::macros::EventContent;
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
@ -45,14 +44,14 @@
//! }
//! ```
//!
//! This can be used with ruma-events structs, such as passing it into
//! This can be used with events structs, such as passing it into
//! `ruma::api::client::state::send_state_event`'s `Request`.
//!
//! As a more advanced example we create a reaction message event. For this event we will use a
//! `SyncMessageLikeEvent` struct but any `MessageLikeEvent` struct would work.
//! [`SyncMessageLikeEvent`] struct but any [`MessageLikeEvent`] struct would work.
//!
//! ```rust
//! use ruma_events::{macros::EventContent, SyncMessageLikeEvent};
//! use ruma_common::events::{macros::EventContent, SyncMessageLikeEvent};
//! use ruma_identifiers::EventId;
//! use serde::{Deserialize, Serialize};
//!
@ -113,9 +112,9 @@
//!
//! # Serialization and deserialization
//!
//! All concrete event types in ruma-events can be serialized via the `Serialize` trait from
//! [serde](https://serde.rs/) and can be deserialized from as `Raw<EventType>`. In order to
//! handle incoming data that may not conform to `ruma-events`' strict definitions of event
//! All concrete event types in this module can be serialized via the `Serialize` trait from
//! [serde](https://serde.rs/) and can be deserialized from a `Raw<EventType>`. In order to
//! handle incoming data that may not conform to this module's strict definitions of event
//! structures, deserialization will return `Raw::Err` on error. This error covers both
//! structurally invalid JSON data as well as structurally valid JSON that doesn't fulfill
//! additional constraints the matrix specification defines for some event types. The error exposes
@ -127,12 +126,6 @@
//! type alias), allowing content to be converted to and from JSON independently of the surrounding
//! event structure, if needed.
#![recursion_limit = "1024"]
#![warn(missing_docs)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
use std::fmt;
use ruma_identifiers::{EventEncryptionAlgorithm, RoomVersionId};
use ruma_serde::Raw;
use serde::{de::IgnoredAny, Deserialize, Serialize, Serializer};
@ -147,17 +140,13 @@ mod enums;
mod event_kinds;
mod unsigned;
// Hack to allow both ruma-events itself and external crates (or tests) to use procedural macros
// that expect `ruma_events` to exist in the prelude.
extern crate self as ruma_events;
/// Re-exports to allow users to declare their own event types using the
/// macros used internally.
///
/// It is not considered part of ruma-events' public API.
/// It is not considered part of this module's public API.
#[doc(hidden)]
pub mod exports {
pub use ruma_common;
pub use crate as ruma_common;
pub use ruma_identifiers;
pub use ruma_serde;
pub use serde;
@ -414,19 +403,6 @@ pub struct UnsignedDeHelper {
pub redacted_because: Option<IgnoredAny>,
}
// Wrapper around `Box<str>` that cannot be used in a meaningful way outside of
// this crate. Used for string enums because their `_Custom` variant can't be
// truly private (only `#[doc(hidden)]`).
#[doc(hidden)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct PrivOwnedStr(Box<str>);
impl fmt::Debug for PrivOwnedStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
/// Helper function for erroring when trying to serialize an event enum _Custom variant that can
/// only be created by deserializing from an unknown event type.
#[doc(hidden)]

View File

@ -2,7 +2,7 @@ use ruma_identifiers::RoomVersionId;
use serde::Serialize;
use serde_json::value::RawValue as RawJsonValue;
use crate::{
use super::{
EphemeralRoomEventContent, EventContent, GlobalAccountDataEventContent, HasDeserializeFields,
MessageLikeEventContent, RedactContent, RedactedEventContent, RedactedMessageLikeEventContent,
RedactedStateEventContent, RoomAccountDataEventContent, StateEventContent,

View File

@ -5,7 +5,7 @@
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::{message::MessageContent, room::message::Relation};
use super::{message::MessageContent, room::message::Relation};
/// The payload for an extensible emote message.
#[derive(Clone, Debug, Serialize, Deserialize, EventContent)]

View File

@ -5,7 +5,7 @@ use ruma_serde::from_raw_json_value;
use serde::{de, Deserialize};
use serde_json::value::RawValue as RawJsonValue;
use crate::{
use super::{
key,
room::{encrypted, redaction::SyncRoomRedactionEvent},
Redact, UnsignedDeHelper,
@ -327,7 +327,7 @@ impl AnyMessageLikeEventContent {
/// This is a helper function intended for encryption. There should not be a reason to access
/// `m.relates_to` without first destructuring an `AnyMessageLikeEventContent` otherwise.
pub fn relation(&self) -> Option<encrypted::Relation> {
use crate::key::verification::{
use super::key::verification::{
accept::KeyVerificationAcceptEventContent, cancel::KeyVerificationCancelEventContent,
done::KeyVerificationDoneEventContent, key::KeyVerificationKeyEventContent,
mac::KeyVerificationMacEventContent, ready::KeyVerificationReadyEventContent,
@ -350,7 +350,7 @@ impl AnyMessageLikeEventContent {
}
#[cfg(feature = "unstable-msc2677")]
Self::Reaction(ev) => {
use crate::reaction;
use super::reaction;
let reaction::Relation { event_id, emoji } = &ev.relates_to;
Some(encrypted::Relation::Annotation(encrypted::Annotation {

View File

@ -5,7 +5,7 @@ use ruma_identifiers::{EventId, RoomId, UserId};
use ruma_macros::Event;
use serde::{Deserialize, Serialize};
use crate::{
use super::{
EphemeralRoomEventContent, GlobalAccountDataEventContent, MessageLikeEventContent,
RedactedMessageLikeEventContent, RedactedStateEventContent, RedactedUnsigned,
RoomAccountDataEventContent, StateEventContent, ToDeviceEventContent, Unsigned,

View File

@ -10,7 +10,7 @@ use ruma_macros::EventContent;
use ruma_serde::Base64;
use serde::{Deserialize, Serialize};
use crate::{
use super::{
message::MessageContent,
room::{message::Relation, JsonWebKey},
};

View File

@ -32,7 +32,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{IgnoredUserListEvent, IgnoredUserListEventContent};
use crate::{AnyGlobalAccountDataEvent, GlobalAccountDataEvent};
use crate::events::{AnyGlobalAccountDataEvent, GlobalAccountDataEvent};
#[test]
fn serialization() {

View File

@ -177,7 +177,7 @@ mod tests {
MessageAuthenticationCode, SasV1Content, ShortAuthenticationString,
ToDeviceKeyVerificationAcceptEventContent, _CustomContent,
};
use crate::{key::verification::Relation, ToDeviceEvent};
use crate::events::{key::verification::Relation, ToDeviceEvent};
#[test]
fn serialization() {

View File

@ -54,7 +54,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::KeyVerificationDoneEventContent;
use crate::key::verification::Relation;
use crate::events::key::verification::Relation;
#[test]
fn serialization() {

View File

@ -79,7 +79,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{KeyVerificationReadyEventContent, ToDeviceKeyVerificationReadyEventContent};
use crate::key::verification::{Relation, VerificationMethod};
use crate::events::key::verification::{Relation, VerificationMethod};
#[test]
fn serialization() {

View File

@ -213,7 +213,7 @@ mod tests {
ShortAuthenticationString, StartMethod, ToDeviceKeyVerificationStartEventContent,
_CustomContent,
};
use crate::{key::verification::Relation, ToDeviceEvent};
use crate::events::{key::verification::Relation, ToDeviceEvent};
#[test]
fn serialization() {

View File

@ -9,7 +9,7 @@ mod content_serde;
use content_serde::MessageContentSerDeHelper;
use crate::room::message::Relation;
use super::room::message::Relation;
/// Text message content.
#[derive(Clone, Debug, Serialize, Deserialize)]

View File

@ -5,7 +5,7 @@
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::{message::MessageContent, room::message::Relation};
use super::{message::MessageContent, room::message::Relation};
/// The payload for an extensible notice message.
#[derive(Clone, Debug, Serialize, Deserialize, EventContent)]

View File

@ -16,7 +16,7 @@ use serde::{
};
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
use crate::EventType;
use super::EventType;
/// Enum for PDU schemas
#[derive(Clone, Debug, Serialize)]

View File

@ -5,7 +5,7 @@
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::policy::rule::PolicyRuleEventContent;
use super::PolicyRuleEventContent;
/// The content of an `m.policy.rule.room` event.
///
@ -26,7 +26,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{PolicyRuleRoomEvent, PolicyRuleRoomEventContent};
use crate::{
use crate::events::{
policy::rule::{PolicyRuleEventContent, Recommendation},
Unsigned,
};

View File

@ -5,7 +5,7 @@
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::policy::rule::PolicyRuleEventContent;
use super::PolicyRuleEventContent;
/// The content of an `m.policy.rule.server` event.
///

View File

@ -5,7 +5,7 @@
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::policy::rule::PolicyRuleEventContent;
use super::PolicyRuleEventContent;
/// The content of an `m.policy.rule.user` event.
///

View File

@ -8,7 +8,7 @@ use ruma_identifiers::{MxcUri, UserId};
use ruma_macros::{Event, EventContent};
use serde::{Deserialize, Serialize};
use crate::{EventKind, StaticEventContent};
use super::{EventKind, StaticEventContent};
/// Presence event.
#[derive(Clone, Debug, Event)]

View File

@ -5,7 +5,7 @@ use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
use crate::{
use crate::events::{
EventContent, HasDeserializeFields, RedactContent, RedactedEventContent,
RedactedStateEventContent,
};

View File

@ -44,7 +44,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::RoomCanonicalAliasEventContent;
use crate::{StateEvent, Unsigned};
use crate::events::{StateEvent, Unsigned};
#[test]
fn serialization_with_optional_fields_as_none() {

View File

@ -9,7 +9,7 @@ use ruma_identifiers::{DeviceId, EventId};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::room::message::{self, InReplyTo};
use super::message::{self, InReplyTo};
mod relation_serde;
@ -122,7 +122,7 @@ impl From<message::Relation> for Relation {
/// The event this relation belongs to replaces another event.
///
/// In contrast to [`message::Replacement`](crate::room::message::Replacement), this struct doesn't
/// In contrast to [`message::Replacement`](super::message::Replacement), this struct doesn't
/// store the new content, since that is part of the encrypted content of an `m.room.encrypted`
/// events.
#[derive(Clone, Debug, Deserialize, Serialize)]
@ -263,9 +263,9 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{
EncryptedEventScheme, MegolmV1AesSha2Content, Relation, RoomEncryptedEventContent,
EncryptedEventScheme, InReplyTo, MegolmV1AesSha2Content, Relation,
RoomEncryptedEventContent,
};
use crate::room::message::InReplyTo;
#[test]
fn serialization() {

View File

@ -6,7 +6,7 @@ use js_int::UInt;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::EventEncryptionAlgorithm;
use crate::events::EventEncryptionAlgorithm;
/// The content of an `m.room.encryption` event.
///

View File

@ -11,8 +11,11 @@ use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
use crate::{
EventContent, HasDeserializeFields, PrivOwnedStr, RedactContent, RedactedEventContent,
RedactedStateEventContent, StrippedStateEvent, SyncStateEvent,
events::{
EventContent, HasDeserializeFields, RedactContent, RedactedEventContent,
RedactedStateEventContent, StrippedStateEvent, SyncStateEvent,
},
PrivOwnedStr,
};
/// The content of an `m.room.member` event.
@ -30,8 +33,8 @@ use crate::{
///
/// This event may also include an `invite_room_state` key inside the event's unsigned data. If
/// present, this contains an array of `StrippedState` events. These events provide information
/// on a subset of state events such as the room name. Note that ruma-events treats unsigned
/// data on events as arbitrary JSON values, and the ruma-events types for this event don't
/// on a subset of state events such as the room name. Note that Ruma treats unsigned
/// data on events as arbitrary JSON values, and the Ruma types for this event don't
/// provide direct access to `invite_room_state`. If you need this data, you must extract and
/// convert it from a `serde_json::Value` yourself.
///
@ -421,7 +424,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json};
use super::{MembershipState, RoomMemberEventContent, SignedContent, ThirdPartyInvite};
use crate::StateEvent;
use crate::events::StateEvent;
#[test]
fn serde_with_no_prev_content() {

View File

@ -12,7 +12,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value as JsonValue;
use super::{EncryptedFile, ImageInfo, ThumbnailInfo};
use crate::{key::verification::VerificationMethod, PrivOwnedStr};
use crate::{events::key::verification::VerificationMethod, PrivOwnedStr};
mod content_serde;
pub mod feedback;
@ -103,7 +103,8 @@ impl RoomMessageEventContent {
/// Different from `text_reply_plain`, this constructor requires specifically a
/// [`RoomMessageEvent`] since it creates a permalink to the previous message, for which the
/// room ID is required. If you want to reply to a [`SyncRoomMessageEvent`], you have to convert
/// it first by calling [`.into_full_event()`][crate::SyncMessageLikeEvent::into_full_event].
/// it first by calling
/// [`.into_full_event()`][crate::events::SyncMessageLikeEvent::into_full_event].
pub fn text_reply_html(
reply: impl fmt::Display,
html_reply: impl fmt::Display,
@ -144,7 +145,8 @@ impl RoomMessageEventContent {
/// Different from `notice_reply_plain`, this constructor requires specifically a
/// [`RoomMessageEvent`] since it creates a permalink to the previous message, for which the
/// room ID is required. If you want to reply to a [`SyncRoomMessageEvent`], you have to convert
/// it first by calling [`.into_full_event()`][crate::SyncMessageLikeEvent::into_full_event].
/// it first by calling
/// [`.into_full_event()`][crate::events::SyncMessageLikeEvent::into_full_event].
pub fn notice_reply_html(
reply: impl fmt::Display,
html_reply: impl fmt::Display,

View File

@ -4,9 +4,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "unstable-msc2676")]
use super::Replacement;
use super::{InReplyTo, Relation};
#[cfg(feature = "unstable-msc2676")]
use crate::room::message::RoomMessageEventContent;
use super::RoomMessageEventContent;
use super::{InReplyTo, Relation};
impl<'de> Deserialize<'de> for Relation {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>

View File

@ -301,8 +301,7 @@ fn formatted_or_plain_body<'a>(formatted: &'a Option<FormattedBody>, body: &'a s
mod tests {
use ruma_identifiers::{event_id, room_id, user_id};
use super::RoomMessageEvent;
use crate::room::message::RoomMessageEventContent;
use super::{RoomMessageEvent, RoomMessageEventContent};
#[test]
fn plain_quote_fallback_multiline() {
@ -313,7 +312,7 @@ mod tests {
sender: user_id!("@alice:example.com").to_owned(),
origin_server_ts: ruma_common::MilliSecondsSinceUnixEpoch::now(),
room_id: room_id!("!n8f893n9:example.com").to_owned(),
unsigned: crate::Unsigned::new(),
unsigned: crate::events::Unsigned::new(),
}),
"> <@alice:example.com> multi\n> line"
);

View File

@ -37,7 +37,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::RoomNameEventContent;
use crate::{StateEvent, Unsigned};
use crate::events::{StateEvent, Unsigned};
#[test]
fn serialization_with_optional_fields_as_none() {

View File

@ -32,7 +32,7 @@ mod tests {
use ruma_identifiers::{server_name, EventId, RoomId, UserId};
use super::RoomPinnedEventsEventContent;
use crate::{StateEvent, Unsigned};
use crate::events::{StateEvent, Unsigned};
#[test]
fn serialization_deserialization() {

View File

@ -10,7 +10,7 @@ use ruma_identifiers::UserId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::EventType;
use crate::events::EventType;
/// The content of an `m.room.power_levels` event.
///
@ -181,7 +181,7 @@ mod tests {
use serde_json::{json, to_value as to_json_value};
use super::{default_power_level, NotificationPowerLevels, RoomPowerLevelsEventContent};
use crate::{EventType, StateEvent, Unsigned};
use crate::events::{EventType, StateEvent, Unsigned};
#[test]
fn serialization_with_optional_fields_as_none() {

View File

@ -7,7 +7,7 @@ use ruma_identifiers::{EventId, RoomId, UserId};
use ruma_macros::{Event, EventContent};
use serde::{Deserialize, Serialize};
use crate::{Redact, RedactContent, RedactedUnsigned, Unsigned};
use crate::events::{Redact, RedactContent, RedactedUnsigned, Unsigned};
/// Redaction event.
#[derive(Clone, Debug, Event)]

View File

@ -67,7 +67,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json};
use super::RoomServerAclEventContent;
use crate::StateEvent;
use crate::events::StateEvent;
#[test]
fn default_values() {

View File

@ -47,7 +47,7 @@ mod tests {
use serde_json::{json, to_value as to_json_value};
use super::ToDeviceRoomKeyEventContent;
use crate::ToDeviceEvent;
use crate::events::ToDeviceEvent;
#[test]
fn serialization() {

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