Enforce import grouping
Includes a few manual changes to make rustfmt behave a bit better.
This commit is contained in:
parent
7dee1d64be
commit
8e10064364
@ -1,6 +1,7 @@
|
||||
comment_width = 100
|
||||
format_code_in_doc_comments = true
|
||||
imports_granularity = "Crate"
|
||||
group_imports = "StdExternalCrate"
|
||||
newline_style = "Unix"
|
||||
use_field_init_shorthand = true
|
||||
use_small_heuristics = "Max"
|
||||
|
@ -10,9 +10,8 @@ use js_int::UInt;
|
||||
use ruma_common::{serde::StringEnum, OwnedRoomId, OwnedUserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
pub use self::{lazy_load::LazyLoadOptions, url::UrlFilter};
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
/// Format to use for returned events.
|
||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
||||
|
@ -19,9 +19,8 @@ pub mod v3 {
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
pub use super::iter::SignedKeysIter;
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use std::{collections::BTreeMap, time::Duration};
|
||||
|
||||
use super::{DeviceLists, UnreadNotificationsCount};
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
@ -20,6 +19,7 @@ use ruma_common::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{DeviceLists, UnreadNotificationsCount};
|
||||
use crate::filter::FilterDefinition;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
use std::{collections::BTreeMap, time::Duration};
|
||||
|
||||
use super::{DeviceLists, UnreadNotificationsCount};
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
@ -21,6 +20,8 @@ use ruma_common::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{DeviceLists, UnreadNotificationsCount};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: POST,
|
||||
rate_limited: false,
|
||||
|
@ -104,10 +104,11 @@ impl<'de> Deserialize<'de> for UserIdentifier {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::uiaa::UserIdentifier;
|
||||
use assert_matches2::assert_matches;
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
use crate::uiaa::UserIdentifier;
|
||||
|
||||
#[test]
|
||||
fn serialize() {
|
||||
assert_eq!(
|
||||
|
@ -17,8 +17,83 @@ use std::{convert::TryInto as _, error::Error as StdError};
|
||||
use bytes::BufMut;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use self::error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError};
|
||||
use crate::UserId;
|
||||
|
||||
/// Convenient constructor for [`Metadata`] constants.
|
||||
///
|
||||
/// Usage:
|
||||
///
|
||||
/// ```
|
||||
/// # use ruma_common::{metadata, api::Metadata};
|
||||
/// const _: Metadata = metadata! {
|
||||
/// method: GET, // one of the associated constants of http::Method
|
||||
/// rate_limited: true,
|
||||
/// authentication: AccessToken, // one of the variants of api::AuthScheme
|
||||
///
|
||||
/// // history of endpoint paths
|
||||
/// // there must be at least one path but otherwise everything is optional
|
||||
/// history: {
|
||||
/// unstable => "/_matrix/foo/org.bar.msc9000/baz",
|
||||
/// unstable => "/_matrix/foo/org.bar.msc9000/qux",
|
||||
/// 1.0 => "/_matrix/media/r0/qux",
|
||||
/// 1.1 => "/_matrix/media/v3/qux",
|
||||
/// 1.2 => deprecated,
|
||||
/// 1.3 => removed,
|
||||
/// }
|
||||
/// };
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! metadata {
|
||||
( $( $field:ident: $rhs:tt ),+ $(,)? ) => {
|
||||
$crate::api::Metadata {
|
||||
$( $field: $crate::metadata!(@field $field: $rhs) ),+
|
||||
}
|
||||
};
|
||||
|
||||
( @field method: $method:ident ) => { $crate::exports::http::Method::$method };
|
||||
|
||||
( @field authentication: $scheme:ident ) => { $crate::api::AuthScheme::$scheme };
|
||||
|
||||
( @field history: {
|
||||
$( unstable => $unstable_path:literal, )*
|
||||
$( $( $version:literal => $rhs:tt, )+ )?
|
||||
} ) => {
|
||||
$crate::metadata! {
|
||||
@history_impl
|
||||
[ $($unstable_path),* ]
|
||||
// Flip left and right to avoid macro parsing ambiguities
|
||||
$( $( $rhs = $version ),+ )?
|
||||
}
|
||||
};
|
||||
|
||||
// Simple literal case: used for description, name, rate_limited
|
||||
( @field $_field:ident: $rhs:expr ) => { $rhs };
|
||||
|
||||
( @history_impl
|
||||
[ $($unstable_path:literal),* ]
|
||||
$(
|
||||
$( $stable_path:literal = $version:literal ),+
|
||||
$(,
|
||||
deprecated = $deprecated_version:literal
|
||||
$(, removed = $removed_version:literal )?
|
||||
)?
|
||||
)?
|
||||
) => {
|
||||
$crate::api::VersionHistory::new(
|
||||
&[ $( $unstable_path ),* ],
|
||||
&[ $($(
|
||||
($crate::api::MatrixVersion::from_lit(stringify!($version)), $stable_path)
|
||||
),+)? ],
|
||||
$crate::metadata!(@optional_version $($( $deprecated_version )?)?),
|
||||
$crate::metadata!(@optional_version $($($( $removed_version )?)?)?),
|
||||
)
|
||||
};
|
||||
|
||||
( @optional_version ) => { None };
|
||||
( @optional_version $version:literal ) => { Some($crate::api::MatrixVersion::from_lit(stringify!($version))) }
|
||||
}
|
||||
|
||||
/// Generates [`OutgoingRequest`] and [`IncomingRequest`] implementations.
|
||||
///
|
||||
/// The `OutgoingRequest` impl is on the `Request` type this attribute is used on. It is
|
||||
@ -134,7 +209,6 @@ use crate::UserId;
|
||||
/// }
|
||||
/// ```
|
||||
pub use ruma_macros::request;
|
||||
|
||||
/// Generates [`OutgoingResponse`] and [`IncomingResponse`] implementations.
|
||||
///
|
||||
/// The `OutgoingRequest` impl is feature-gated behind `cfg(feature = "client")`.
|
||||
@ -230,9 +304,7 @@ pub use ruma_macros::response;
|
||||
pub mod error;
|
||||
mod metadata;
|
||||
|
||||
pub use metadata::{MatrixVersion, Metadata, VersionHistory, VersioningDecision};
|
||||
|
||||
use error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError};
|
||||
pub use self::metadata::{MatrixVersion, Metadata, VersionHistory, VersioningDecision};
|
||||
|
||||
/// An enum to control whether an access token should be added to outgoing requests
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
@ -435,77 +507,3 @@ pub enum Direction {
|
||||
#[serde(rename = "f")]
|
||||
Forward,
|
||||
}
|
||||
|
||||
/// Convenient constructor for [`Metadata`] constants.
|
||||
///
|
||||
/// Usage:
|
||||
///
|
||||
/// ```
|
||||
/// # use ruma_common::{metadata, api::Metadata};
|
||||
/// const _: Metadata = metadata! {
|
||||
/// method: GET, // one of the associated constants of http::Method
|
||||
/// rate_limited: true,
|
||||
/// authentication: AccessToken, // one of the variants of api::AuthScheme
|
||||
///
|
||||
/// // history of endpoint paths
|
||||
/// // there must be at least one path but otherwise everything is optional
|
||||
/// history: {
|
||||
/// unstable => "/_matrix/foo/org.bar.msc9000/baz",
|
||||
/// unstable => "/_matrix/foo/org.bar.msc9000/qux",
|
||||
/// 1.0 => "/_matrix/media/r0/qux",
|
||||
/// 1.1 => "/_matrix/media/v3/qux",
|
||||
/// 1.2 => deprecated,
|
||||
/// 1.3 => removed,
|
||||
/// }
|
||||
/// };
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! metadata {
|
||||
( $( $field:ident: $rhs:tt ),+ $(,)? ) => {
|
||||
$crate::api::Metadata {
|
||||
$( $field: $crate::metadata!(@field $field: $rhs) ),+
|
||||
}
|
||||
};
|
||||
|
||||
( @field method: $method:ident ) => { $crate::exports::http::Method::$method };
|
||||
|
||||
( @field authentication: $scheme:ident ) => { $crate::api::AuthScheme::$scheme };
|
||||
|
||||
( @field history: {
|
||||
$( unstable => $unstable_path:literal, )*
|
||||
$( $( $version:literal => $rhs:tt, )+ )?
|
||||
} ) => {
|
||||
$crate::metadata! {
|
||||
@history_impl
|
||||
[ $($unstable_path),* ]
|
||||
// Flip left and right to avoid macro parsing ambiguities
|
||||
$( $( $rhs = $version ),+ )?
|
||||
}
|
||||
};
|
||||
|
||||
// Simple literal case: used for description, name, rate_limited
|
||||
( @field $_field:ident: $rhs:expr ) => { $rhs };
|
||||
|
||||
( @history_impl
|
||||
[ $($unstable_path:literal),* ]
|
||||
$(
|
||||
$( $stable_path:literal = $version:literal ),+
|
||||
$(,
|
||||
deprecated = $deprecated_version:literal
|
||||
$(, removed = $removed_version:literal )?
|
||||
)?
|
||||
)?
|
||||
) => {
|
||||
$crate::api::VersionHistory::new(
|
||||
&[ $( $unstable_path ),* ],
|
||||
&[ $($(
|
||||
($crate::api::MatrixVersion::from_lit(stringify!($version)), $stable_path)
|
||||
),+)? ],
|
||||
$crate::metadata!(@optional_version $($( $deprecated_version )?)?),
|
||||
$crate::metadata!(@optional_version $($($( $removed_version )?)?)?),
|
||||
)
|
||||
};
|
||||
|
||||
( @optional_version ) => { None };
|
||||
( @optional_version $version:literal ) => { Some($crate::api::MatrixVersion::from_lit(stringify!($version))) }
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use serde_json::Value as JsonValue;
|
||||
|
||||
mod value;
|
||||
|
||||
pub use self::value::{CanonicalJsonObject, CanonicalJsonValue};
|
||||
use crate::RoomVersionId;
|
||||
#[cfg(feature = "events")]
|
||||
use crate::{
|
||||
@ -14,8 +15,6 @@ use crate::{
|
||||
serde::Raw,
|
||||
};
|
||||
|
||||
pub use self::value::{CanonicalJsonObject, CanonicalJsonValue};
|
||||
|
||||
/// The set of possible errors when serializing to canonical JSON.
|
||||
#[cfg(feature = "canonical-json")]
|
||||
#[derive(Debug)]
|
||||
|
@ -3,12 +3,11 @@ use std::fmt;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
||||
|
||||
use crate::serde::{CanBeEmpty, Raw};
|
||||
|
||||
use super::{
|
||||
EphemeralRoomEventType, GlobalAccountDataEventType, MessageLikeEventType,
|
||||
RoomAccountDataEventType, StateEventType, ToDeviceEventType,
|
||||
};
|
||||
use crate::serde::{CanBeEmpty, Raw};
|
||||
|
||||
/// The base trait that all event content types implement.
|
||||
///
|
||||
|
@ -59,10 +59,10 @@ impl FromIterator<(OwnedUserId, Vec<OwnedRoomId>)> for DirectEventContent {
|
||||
mod tests {
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::{server_name, RoomId, UserId};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
use super::{DirectEvent, DirectEventContent};
|
||||
use crate::{server_name, RoomId, UserId};
|
||||
|
||||
#[test]
|
||||
fn serialization() {
|
||||
|
@ -9,13 +9,12 @@ use std::collections::{BTreeMap, BTreeSet};
|
||||
use indexmap::IndexMap;
|
||||
use js_int::uint;
|
||||
|
||||
use crate::{MilliSecondsSinceUnixEpoch, UserId};
|
||||
|
||||
use self::{
|
||||
response::OriginalSyncPollResponseEvent, start::PollContentBlock,
|
||||
unstable_response::OriginalSyncUnstablePollResponseEvent,
|
||||
unstable_start::UnstablePollStartContentBlock,
|
||||
};
|
||||
use crate::{MilliSecondsSinceUnixEpoch, UserId};
|
||||
|
||||
pub mod end;
|
||||
pub mod response;
|
||||
|
@ -5,9 +5,8 @@ use std::{ops::Deref, vec};
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{events::relation::Reference, OwnedEventId};
|
||||
|
||||
use super::start::PollContentBlock;
|
||||
use crate::{events::relation::Reference, OwnedEventId};
|
||||
|
||||
/// The payload for a poll response event.
|
||||
///
|
||||
|
@ -10,18 +10,17 @@ mod poll_answers_serde;
|
||||
|
||||
use poll_answers_serde::PollAnswersDeHelper;
|
||||
|
||||
use crate::{
|
||||
events::{message::TextContentBlock, room::message::Relation},
|
||||
serde::StringEnum,
|
||||
PrivOwnedStr,
|
||||
};
|
||||
|
||||
use super::{
|
||||
compile_poll_results,
|
||||
end::{PollEndEventContent, PollResultsContentBlock},
|
||||
generate_poll_end_fallback_text,
|
||||
response::OriginalSyncPollResponseEvent,
|
||||
};
|
||||
use crate::{
|
||||
events::{message::TextContentBlock, room::message::Relation},
|
||||
serde::StringEnum,
|
||||
PrivOwnedStr,
|
||||
};
|
||||
|
||||
/// The payload for a poll start event.
|
||||
///
|
||||
|
@ -6,9 +6,8 @@ use std::ops::Deref;
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{events::relation::Reference, OwnedEventId};
|
||||
|
||||
use super::unstable_start::UnstablePollStartContentBlock;
|
||||
use crate::{events::relation::Reference, OwnedEventId};
|
||||
|
||||
/// The payload for an unstable poll response event.
|
||||
///
|
||||
|
@ -9,8 +9,6 @@ use serde::{Deserialize, Serialize};
|
||||
mod unstable_poll_answers_serde;
|
||||
mod unstable_poll_kind_serde;
|
||||
|
||||
use crate::events::room::message::Relation;
|
||||
|
||||
use self::unstable_poll_answers_serde::UnstablePollAnswersDeHelper;
|
||||
use super::{
|
||||
compile_unstable_poll_results, generate_poll_end_fallback_text,
|
||||
@ -18,6 +16,7 @@ use super::{
|
||||
unstable_end::UnstablePollEndEventContent,
|
||||
unstable_response::OriginalSyncUnstablePollResponseEvent,
|
||||
};
|
||||
use crate::events::room::message::Relation;
|
||||
|
||||
/// The payload for an unstable poll start event.
|
||||
///
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::events::poll::start::{PollAnswers, PollAnswersError};
|
||||
|
||||
use super::{UnstablePollAnswer, UnstablePollAnswers};
|
||||
use crate::events::poll::start::{PollAnswers, PollAnswersError};
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
pub(crate) struct UnstablePollAnswersDeHelper(Vec<UnstablePollAnswer>);
|
||||
|
@ -282,9 +282,8 @@ mod tests {
|
||||
use serde::Deserialize;
|
||||
use serde_json::{from_value as from_json_value, json};
|
||||
|
||||
use crate::{mxc_uri, serde::Base64};
|
||||
|
||||
use super::{EncryptedFile, JsonWebKey, MediaSource};
|
||||
use crate::{mxc_uri, serde::Base64};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct MsgWithAttachment {
|
||||
|
@ -124,13 +124,12 @@ pub(crate) fn plain_and_formatted_reply_body(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::OriginalRoomMessageEvent;
|
||||
use crate::{
|
||||
events::{room::message::RoomMessageEventContent, MessageLikeUnsigned},
|
||||
owned_event_id, owned_room_id, owned_user_id, MilliSecondsSinceUnixEpoch,
|
||||
};
|
||||
|
||||
use super::OriginalRoomMessageEvent;
|
||||
|
||||
#[test]
|
||||
fn fallback_multiline() {
|
||||
let (plain_quote, html_quote) =
|
||||
|
@ -5,9 +5,8 @@ use serde::{
|
||||
Deserialize, Deserializer,
|
||||
};
|
||||
|
||||
use crate::OwnedMxcUri;
|
||||
|
||||
use super::{EncryptedFile, MediaSource};
|
||||
use crate::OwnedMxcUri;
|
||||
|
||||
/// Serializes a MediaSource to a thumbnail source.
|
||||
pub(crate) fn serialize<S>(source: &Option<MediaSource>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
@ -44,10 +44,10 @@ impl ToDeviceRoomKeyEventContent {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{owned_room_id, EventEncryptionAlgorithm};
|
||||
use serde_json::{json, to_value as to_json_value};
|
||||
|
||||
use super::ToDeviceRoomKeyEventContent;
|
||||
use crate::{owned_room_id, EventEncryptionAlgorithm};
|
||||
|
||||
#[test]
|
||||
fn serialization() {
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::serde::Base64;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::serde::Base64;
|
||||
|
||||
/// A secret and its encrypted contents.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
|
@ -7,10 +7,9 @@ use std::{collections::BTreeMap, error::Error, fmt, str::FromStr};
|
||||
use ruma_macros::EventContent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{serde::deserialize_cow_str, PrivOwnedStr};
|
||||
|
||||
#[cfg(feature = "compat-tag-info")]
|
||||
use crate::serde::deserialize_as_optional_f64_or_string;
|
||||
use crate::{serde::deserialize_cow_str, PrivOwnedStr};
|
||||
|
||||
/// Map of tag names to tag info.
|
||||
pub type Tags = BTreeMap<TagName, TagInfo>;
|
||||
|
@ -4,6 +4,11 @@
|
||||
// FIXME: Remove once lint doesn't trigger on std::convert::TryFrom in identifiers/macros.rs anymore
|
||||
#![allow(unused_qualifications)]
|
||||
|
||||
#[doc(inline)]
|
||||
pub use ruma_identifiers_validation::error::{
|
||||
Error as IdParseError, MatrixIdError, MatrixToError, MatrixUriError, MxcUriError,
|
||||
VoipVersionIdError,
|
||||
};
|
||||
use serde::de::{self, Deserializer, Unexpected};
|
||||
|
||||
#[doc(inline)]
|
||||
@ -34,11 +39,6 @@ pub use self::{
|
||||
voip_id::{OwnedVoipId, VoipId},
|
||||
voip_version_id::VoipVersionId,
|
||||
};
|
||||
#[doc(inline)]
|
||||
pub use ruma_identifiers_validation::error::{
|
||||
Error as IdParseError, MatrixIdError, MatrixToError, MatrixUriError, MxcUriError,
|
||||
VoipVersionIdError,
|
||||
};
|
||||
|
||||
pub mod matrix_uri;
|
||||
pub mod user_id;
|
||||
|
@ -1,7 +1,8 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use js_int::Int;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde_json::{to_value as to_json_value, value::Value as JsonValue};
|
||||
use std::collections::BTreeMap;
|
||||
use thiserror::Error;
|
||||
use tracing::{instrument, warn};
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
use serde::{de, Deserialize, Serialize, Serializer};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
use crate::serde::from_raw_json_value;
|
||||
|
||||
#[cfg(feature = "unstable-msc3931")]
|
||||
use super::RoomVersionFeature;
|
||||
use super::{PushCondition, RoomMemberCountIs, ScalarJsonValue};
|
||||
use crate::serde::from_raw_json_value;
|
||||
|
||||
impl Serialize for PushCondition {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
@ -1,13 +1,7 @@
|
||||
use assert_matches2::assert_matches;
|
||||
use js_int::int;
|
||||
use ruma_common::{
|
||||
events::{MessageLikeEvent, StateEvent, SyncMessageLikeEvent, SyncStateEvent},
|
||||
room_alias_id,
|
||||
serde::test::serde_json_eq,
|
||||
};
|
||||
use serde_json::{from_value as from_json_value, json, Value as JsonValue};
|
||||
|
||||
use ruma_common::events::{
|
||||
events::{
|
||||
room::{
|
||||
aliases::RoomAliasesEventContent,
|
||||
message::{MessageType, RoomMessageEventContent},
|
||||
@ -15,10 +9,15 @@ use ruma_common::events::{
|
||||
},
|
||||
AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent, AnySyncMessageLikeEvent,
|
||||
AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent, EphemeralRoomEventType,
|
||||
GlobalAccountDataEventType, MessageLikeEventType, OriginalMessageLikeEvent, OriginalStateEvent,
|
||||
OriginalSyncMessageLikeEvent, OriginalSyncStateEvent, RoomAccountDataEventType, StateEventType,
|
||||
ToDeviceEventType,
|
||||
GlobalAccountDataEventType, MessageLikeEvent, MessageLikeEventType,
|
||||
OriginalMessageLikeEvent, OriginalStateEvent, OriginalSyncMessageLikeEvent,
|
||||
OriginalSyncStateEvent, RoomAccountDataEventType, StateEvent, StateEventType,
|
||||
SyncMessageLikeEvent, SyncStateEvent, ToDeviceEventType,
|
||||
},
|
||||
room_alias_id,
|
||||
serde::test::serde_json_eq,
|
||||
};
|
||||
use serde_json::{from_value as from_json_value, json, Value as JsonValue};
|
||||
|
||||
fn message_event() -> JsonValue {
|
||||
json!({
|
||||
|
@ -2,16 +2,15 @@ use assert_matches2::assert_matches;
|
||||
use js_int::uint;
|
||||
use maplit::btreemap;
|
||||
use ruma_common::{
|
||||
event_id, events::receipt::ReceiptType, owned_event_id, owned_user_id, user_id,
|
||||
MilliSecondsSinceUnixEpoch,
|
||||
};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
use ruma_common::events::{
|
||||
receipt::{Receipt, ReceiptEventContent},
|
||||
event_id,
|
||||
events::{
|
||||
receipt::{Receipt, ReceiptEventContent, ReceiptType},
|
||||
typing::TypingEventContent,
|
||||
AnyEphemeralRoomEvent,
|
||||
},
|
||||
owned_event_id, owned_user_id, user_id, MilliSecondsSinceUnixEpoch,
|
||||
};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
#[test]
|
||||
fn ephemeral_serialize_typing() {
|
||||
|
@ -12,9 +12,8 @@ use syn::{
|
||||
DeriveInput, Field, Ident, LitStr, Meta, Token, Type,
|
||||
};
|
||||
|
||||
use crate::util::{m_prefix_name_to_type_name, PrivateField};
|
||||
|
||||
use super::event_parse::{EventKind, EventKindVariation};
|
||||
use crate::util::{m_prefix_name_to_type_name, PrivateField};
|
||||
|
||||
mod kw {
|
||||
// This `content` field is kept when the event is redacted.
|
||||
|
@ -1,7 +1,6 @@
|
||||
//! Common types for implementing federation authorization.
|
||||
|
||||
use headers::{authorization::Credentials, HeaderValue};
|
||||
|
||||
use ruma_common::{OwnedServerName, OwnedServerSigningKeyId};
|
||||
use tracing::debug;
|
||||
use yap::{IntoTokens, TokenLocation, Tokens};
|
||||
|
@ -90,9 +90,10 @@ impl Ed25519KeyPair {
|
||||
/// generated from the private key. This is a fallback and extra validation against
|
||||
/// corruption or
|
||||
pub fn from_der(document: &[u8], version: String) -> Result<Self, Error> {
|
||||
use pkcs8::der::Decode;
|
||||
|
||||
#[cfg(feature = "ring-compat")]
|
||||
use self::compat::CompatibleDocument;
|
||||
use pkcs8::der::Decode;
|
||||
|
||||
#[cfg(feature = "ring-compat")]
|
||||
let backing: Vec<u8>;
|
||||
|
@ -46,14 +46,16 @@
|
||||
|
||||
use ruma_common::serde::{AsRefStr, DisplayAsRefStr};
|
||||
|
||||
pub use error::{Error, JsonError, ParseError, VerificationError};
|
||||
pub use functions::{
|
||||
pub use self::{
|
||||
error::{Error, JsonError, ParseError, VerificationError},
|
||||
functions::{
|
||||
canonical_json, content_hash, hash_and_sign_event, reference_hash, sign_json, verify_event,
|
||||
verify_json,
|
||||
},
|
||||
keys::{Ed25519KeyPair, KeyPair, PublicKeyMap, PublicKeySet},
|
||||
signatures::Signature,
|
||||
verification::Verified,
|
||||
};
|
||||
pub use keys::{Ed25519KeyPair, KeyPair, PublicKeyMap, PublicKeySet};
|
||||
pub use signatures::Signature;
|
||||
pub use verification::Verified;
|
||||
|
||||
mod error;
|
||||
mod functions;
|
||||
|
@ -27,10 +27,9 @@ use serde_json::{
|
||||
};
|
||||
use tracing::info;
|
||||
|
||||
pub(crate) use self::event::PduEvent;
|
||||
use crate::{auth_types_for_event, Error, Event, EventTypeExt, Result, StateMap};
|
||||
|
||||
pub(crate) use event::PduEvent;
|
||||
|
||||
static SERVER_TIMESTAMP: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
pub(crate) fn do_check(
|
||||
|
@ -98,17 +98,16 @@ pub use ruma_state_res as state_res;
|
||||
/// [apis]: https://spec.matrix.org/latest/#matrix-apis
|
||||
#[cfg(feature = "api")]
|
||||
pub mod api {
|
||||
// The metadata macro is also exported at the crate root because `#[macro_export]` always
|
||||
// places things at the crate root of the defining crate and we do a glob re-export of
|
||||
// `ruma_common`, but here is the more logical (preferred) location.
|
||||
pub use ruma_common::{api::*, metadata};
|
||||
|
||||
#[cfg(any(feature = "appservice-api-c", feature = "appservice-api-s"))]
|
||||
#[doc(inline)]
|
||||
pub use ruma_appservice_api as appservice;
|
||||
#[cfg(any(feature = "client-api-c", feature = "client-api-s"))]
|
||||
#[doc(inline)]
|
||||
pub use ruma_client_api as client;
|
||||
// The metadata macro is also exported at the crate root because `#[macro_export]` always
|
||||
// places things at the crate root of the defining crate and we do a glob re-export of
|
||||
// `ruma_common`, but here is the more logical (preferred) location.
|
||||
pub use ruma_common::{api::*, metadata};
|
||||
#[cfg(any(feature = "federation-api-c", feature = "federation-api-s"))]
|
||||
#[doc(inline)]
|
||||
pub use ruma_federation_api as federation;
|
||||
|
Loading…
x
Reference in New Issue
Block a user