Use new owned ID macros throught the codebase

This commit is contained in:
Jonas Platte 2023-06-20 11:47:50 +02:00
parent e71c224308
commit c5782ab8aa
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C
37 changed files with 172 additions and 182 deletions

View File

@ -87,21 +87,19 @@ pub mod v3 {
fn serialize_request() {
use ruma_common::{
api::{MatrixVersion, OutgoingRequest, SendAccessToken},
user_id,
owned_user_id,
};
use crate::filter::FilterDefinition;
let req = super::Request::new(
user_id!("@foo:bar.com").to_owned(),
FilterDefinition::default(),
)
.try_into_http_request::<Vec<u8>>(
"https://matrix.org",
SendAccessToken::IfRequired("tok"),
&[MatrixVersion::V1_1],
)
.unwrap();
let req =
super::Request::new(owned_user_id!("@foo:bar.com"), FilterDefinition::default())
.try_into_http_request::<Vec<u8>>(
"https://matrix.org",
SendAccessToken::IfRequired("tok"),
&[MatrixVersion::V1_1],
)
.unwrap();
assert_eq!(req.body(), b"{}");
}
}

View File

@ -120,7 +120,7 @@ pub mod v3 {
///
/// ```rust
/// # use ruma_client_api::message::get_message_events;
/// # let room_id = ruma_common::room_id!("!a:example.org").to_owned();
/// # let room_id = ruma_common::owned_room_id!("!a:example.org");
/// # let token = "prev_batch token".to_owned();
/// let request = get_message_events::v3::Request::backward(room_id).from(token);
/// ```
@ -137,7 +137,7 @@ pub mod v3 {
///
/// ```rust
/// # use ruma_client_api::message::get_message_events;
/// # let room_id = ruma_common::room_id!("!a:example.org").to_owned();
/// # let room_id = ruma_common::owned_room_id!("!a:example.org");
/// # let token = "end token".to_owned();
/// let request = get_message_events::v3::Request::forward(room_id).from(token);
/// ```
@ -175,7 +175,7 @@ pub mod v3 {
use js_int::uint;
use ruma_common::{
api::{Direction, MatrixVersion, OutgoingRequest, SendAccessToken},
room_id,
owned_room_id,
};
use super::Request;
@ -183,15 +183,15 @@ pub mod v3 {
#[test]
fn serialize_some_room_event_filter() {
let room_id = room_id!("!roomid:example.org").to_owned();
let room_id = owned_room_id!("!roomid:example.org");
let rooms = vec![room_id.to_owned()];
let filter = RoomEventFilter {
lazy_load_options: LazyLoadOptions::Enabled { include_redundant_members: true },
rooms: Some(rooms),
not_rooms: vec![
room_id!("!room:example.org").to_owned(),
room_id!("!room2:example.org").to_owned(),
room_id!("!room3:example.org").to_owned(),
owned_room_id!("!room:example.org"),
owned_room_id!("!room2:example.org"),
owned_room_id!("!room3:example.org"),
],
not_types: vec!["type".into()],
..Default::default()
@ -224,7 +224,7 @@ pub mod v3 {
#[test]
fn serialize_default_room_event_filter() {
let room_id = room_id!("!roomid:example.org").to_owned();
let room_id = owned_room_id!("!roomid:example.org");
let req = Request {
room_id,
from: Some("token".to_owned()),

View File

@ -210,12 +210,12 @@ pub mod v3 {
use ruma_common::{
api::{MatrixVersion, OutgoingRequest as _, SendAccessToken},
events::{room::name::RoomNameEventContent, EmptyStateKey},
room_id,
owned_room_id,
};
// This used to panic in make_endpoint_url because of a mismatch in the path parameter count
let req = Request::new(
room_id!("!room:server.tld").to_owned(),
owned_room_id!("!room:server.tld"),
&EmptyStateKey,
&RoomNameEventContent::new(Some("Test room".to_owned())),
)

View File

@ -67,13 +67,10 @@
//! # .await?;
//!
//! use ruma_client_api::alias::get_alias;
//! use ruma_common::{api::MatrixVersion, room_alias_id, room_id};
//! use ruma_common::{api::MatrixVersion, owned_room_alias_id, room_id};
//!
//! let response = client
//! .send_request(get_alias::v3::Request::new(
//! room_alias_id!("#example_room:example.com").to_owned(),
//! ))
//! .await?;
//! let alias = owned_room_alias_id!("#example_room:example.com");
//! let response = client.send_request(get_alias::v3::Request::new(alias)).await?;
//!
//! assert_eq!(response.room_id, room_id!("!n8f893n9:example.com"));
//! # Result::<(), ruma_client::Error<_, _>>::Ok(())

View File

@ -55,12 +55,12 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::IgnoredUserListEventContent;
use crate::{events::AnyGlobalAccountDataEvent, user_id};
use crate::{events::AnyGlobalAccountDataEvent, owned_user_id, user_id};
#[test]
fn serialization() {
let ignored_user_list =
IgnoredUserListEventContent::users(vec![user_id!("@carl:example.com").to_owned()]);
IgnoredUserListEventContent::users(vec![owned_user_id!("@carl:example.com")]);
let json = json!({
"ignored_users": {

View File

@ -51,11 +51,11 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::KeyVerificationDoneEventContent;
use crate::{event_id, events::relation::Reference};
use crate::{events::relation::Reference, owned_event_id};
#[test]
fn serialization() {
let event_id = event_id!("$1598361704261elfgc:localhost").to_owned();
let event_id = owned_event_id!("$1598361704261elfgc:localhost");
let json_data = json!({
"m.relates_to": {

View File

@ -78,14 +78,13 @@ mod tests {
use super::{KeyVerificationReadyEventContent, ToDeviceKeyVerificationReadyEventContent};
use crate::{
event_id,
events::{key::verification::VerificationMethod, relation::Reference},
OwnedDeviceId,
owned_event_id, OwnedDeviceId,
};
#[test]
fn serialization() {
let event_id = event_id!("$1598361704261elfgc:localhost").to_owned();
let event_id = owned_event_id!("$1598361704261elfgc:localhost");
let device: OwnedDeviceId = "123".into();
let json_data = json!({

View File

@ -40,7 +40,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::ReactionEventContent;
use crate::{event_id, events::relation::Annotation};
use crate::{events::relation::Annotation, owned_event_id};
#[test]
fn deserialize() {
@ -63,7 +63,7 @@ mod tests {
#[test]
fn serialize() {
let content = ReactionEventContent::new(Annotation::new(
event_id!("$my_reaction").to_owned(),
owned_event_id!("$my_reaction"),
"🏠".to_owned(),
));

View File

@ -215,7 +215,7 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{Receipt, ReceiptThread};
use crate::{event_id, MilliSecondsSinceUnixEpoch};
use crate::{owned_event_id, MilliSecondsSinceUnixEpoch};
#[test]
fn serialize_receipt() {
@ -225,7 +225,7 @@ mod tests {
receipt.thread = ReceiptThread::Main;
assert_eq!(to_json_value(receipt.clone()).unwrap(), json!({ "thread_id": "main" }));
receipt.thread = ReceiptThread::Thread(event_id!("$abcdef76543").to_owned());
receipt.thread = ReceiptThread::Thread(owned_event_id!("$abcdef76543"));
assert_eq!(to_json_value(receipt).unwrap(), json!({ "thread_id": "$abcdef76543" }));
let mut receipt =

View File

@ -42,12 +42,12 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::RoomCanonicalAliasEventContent;
use crate::{events::OriginalStateEvent, room_alias_id};
use crate::{events::OriginalStateEvent, owned_room_alias_id};
#[test]
fn serialization_with_optional_fields_as_none() {
let content = RoomCanonicalAliasEventContent {
alias: Some(room_alias_id!("#somewhere:localhost").to_owned()),
alias: Some(owned_room_alias_id!("#somewhere:localhost")),
alt_aliases: Vec::new(),
};
@ -126,7 +126,7 @@ mod tests {
#[test]
fn nonempty_field_as_some() {
let alias = Some(room_alias_id!("#somewhere:localhost").to_owned());
let alias = Some(owned_room_alias_id!("#somewhere:localhost"));
let json_data = json!({
"content": {
"alias": "#somewhere:localhost"

View File

@ -91,12 +91,12 @@ mod tests {
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
use super::{RoomCreateEventContent, RoomType};
use crate::{user_id, RoomVersionId};
use crate::{owned_user_id, RoomVersionId};
#[test]
fn serialization() {
let content = RoomCreateEventContent {
creator: user_id!("@carl:example.com").to_owned(),
creator: owned_user_id!("@carl:example.com"),
federate: false,
room_version: RoomVersionId::V4,
predecessor: None,
@ -115,7 +115,7 @@ mod tests {
#[test]
fn space_serialization() {
let content = RoomCreateEventContent {
creator: user_id!("@carl:example.com").to_owned(),
creator: owned_user_id!("@carl:example.com"),
federate: false,
room_version: RoomVersionId::V4,
predecessor: None,

View File

@ -251,7 +251,7 @@ mod tests {
EncryptedEventScheme, InReplyTo, MegolmV1AesSha2ContentInit, Relation,
RoomEncryptedEventContent,
};
use crate::{event_id, serde::Raw};
use crate::{owned_event_id, serde::Raw};
#[test]
fn serialization() {
@ -266,7 +266,7 @@ mod tests {
.into(),
),
relates_to: Some(Relation::Reply {
in_reply_to: InReplyTo { event_id: event_id!("$h29iv0s8:example.com").to_owned() },
in_reply_to: InReplyTo { event_id: owned_event_id!("$h29iv0s8:example.com") },
}),
};

View File

@ -248,7 +248,7 @@ mod tests {
use assert_matches2::assert_matches;
use super::{AllowRule, JoinRule, OriginalSyncRoomJoinRulesEvent, RoomJoinRulesEventContent};
use crate::room_id;
use crate::owned_room_id;
#[test]
fn deserialize() {
@ -277,8 +277,8 @@ mod tests {
JoinRule::Restricted(restricted) => assert_eq!(
restricted.allow,
&[
AllowRule::room_membership(room_id!("!mods:example.org").to_owned()),
AllowRule::room_membership(room_id!("!users:example.org").to_owned())
AllowRule::room_membership(owned_room_id!("!mods:example.org")),
AllowRule::room_membership(owned_room_id!("!users:example.org"))
]
),
rule => panic!("Deserialized to wrong variant: {rule:?}"),

View File

@ -542,8 +542,8 @@ mod tests {
use super::{MembershipState, RoomMemberEventContent};
use crate::{
events::OriginalStateEvent, mxc_uri, serde::CanBeEmpty, server_name, server_signing_key_id,
user_id, MilliSecondsSinceUnixEpoch,
events::OriginalStateEvent, mxc_uri, owned_server_signing_key_id, serde::CanBeEmpty,
server_name, user_id, MilliSecondsSinceUnixEpoch,
};
#[test]
@ -667,7 +667,7 @@ mod tests {
third_party_invite.signed.signatures,
btreemap! {
server_name!("magic.forest").to_owned() => btreemap! {
server_signing_key_id!("ed25519:3").to_owned() => "foobar".to_owned()
owned_server_signing_key_id!("ed25519:3") => "foobar".to_owned()
}
}
);
@ -737,7 +737,7 @@ mod tests {
third_party_invite.signed.signatures,
btreemap! {
server_name!("magic.forest").to_owned() => btreemap! {
server_signing_key_id!("ed25519:3").to_owned() => "foobar".to_owned()
owned_server_signing_key_id!("ed25519:3") => "foobar".to_owned()
}
}
);

View File

@ -125,9 +125,8 @@ pub fn plain_and_formatted_reply_body(
#[cfg(test)]
mod tests {
use crate::{
event_id,
events::{room::message::RoomMessageEventContent, MessageLikeUnsigned},
room_id, user_id, MilliSecondsSinceUnixEpoch,
owned_event_id, owned_room_id, owned_user_id, MilliSecondsSinceUnixEpoch,
};
use super::OriginalRoomMessageEvent;
@ -137,10 +136,10 @@ mod tests {
let (plain_quote, html_quote) =
super::get_message_quote_fallbacks(&OriginalRoomMessageEvent {
content: RoomMessageEventContent::text_plain("multi\nline"),
event_id: event_id!("$1598361704261elfgc:localhost").to_owned(),
sender: user_id!("@alice:example.com").to_owned(),
event_id: owned_event_id!("$1598361704261elfgc:localhost"),
sender: owned_user_id!("@alice:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
room_id: room_id!("!n8f893n9:example.com").to_owned(),
room_id: owned_room_id!("!n8f893n9:example.com"),
unsigned: MessageLikeUnsigned::new(),
});

View File

@ -44,7 +44,7 @@ impl ToDeviceRoomKeyEventContent {
#[cfg(test)]
mod tests {
use crate::{room_id, EventEncryptionAlgorithm};
use crate::{owned_room_id, EventEncryptionAlgorithm};
use serde_json::{json, to_value as to_json_value};
use super::ToDeviceRoomKeyEventContent;
@ -53,7 +53,7 @@ mod tests {
fn serialization() {
let content = ToDeviceRoomKeyEventContent {
algorithm: EventEncryptionAlgorithm::MegolmV1AesSha2,
room_id: room_id!("!testroomid:example.org").to_owned(),
room_id: owned_room_id!("!testroomid:example.org"),
session_id: "SessId".into(),
session_key: "SessKey".into(),
};

View File

@ -990,9 +990,9 @@ mod tests {
AnyPushRule, ConditionalPushRule, PatternedPushRule, Ruleset, SimplePushRule,
};
use crate::{
owned_room_id, owned_user_id,
power_levels::NotificationPowerLevels,
push::{PredefinedContentRuleId, PredefinedOverrideRuleId},
room_id,
serde::Raw,
user_id,
};
@ -1124,7 +1124,7 @@ mod tests {
actions: vec![Action::Notify],
default: false,
enabled: false,
rule_id: room_id!("!roomid:server.name").to_owned(),
rule_id: owned_room_id!("!roomid:server.name"),
};
let rule_value: JsonValue = to_json_value(rule).unwrap();
@ -1425,9 +1425,9 @@ mod tests {
let set = Ruleset::server_default(user_id!("@jolly_jumper:server.name"));
let context_one_to_one = &PushConditionRoomCtx {
room_id: room_id!("!dm:server.name").to_owned(),
room_id: owned_room_id!("!dm:server.name"),
member_count: uint!(2),
user_id: user_id!("@jj:server.name").to_owned(),
user_id: owned_user_id!("@jj:server.name"),
user_display_name: "Jolly Jumper".into(),
users_power_levels: BTreeMap::new(),
default_power_level: int!(50),
@ -1437,9 +1437,9 @@ mod tests {
};
let context_public_room = &PushConditionRoomCtx {
room_id: room_id!("!far_west:server.name").to_owned(),
room_id: owned_room_id!("!far_west:server.name"),
member_count: uint!(100),
user_id: user_id!("@jj:server.name").to_owned(),
user_id: owned_user_id!("@jj:server.name"),
user_display_name: "Jolly Jumper".into(),
users_power_levels: BTreeMap::new(),
default_power_level: int!(50),
@ -1530,9 +1530,9 @@ mod tests {
#[test]
fn custom_ruleset_applies() {
let context_one_to_one = &PushConditionRoomCtx {
room_id: room_id!("!dm:server.name").to_owned(),
room_id: owned_room_id!("!dm:server.name"),
member_count: uint!(2),
user_id: user_id!("@jj:server.name").to_owned(),
user_id: owned_user_id!("@jj:server.name"),
user_display_name: "Jolly Jumper".into(),
users_power_levels: BTreeMap::new(),
default_power_level: int!(50),
@ -1587,7 +1587,7 @@ mod tests {
actions: vec![Action::Notify],
default: false,
enabled: true,
rule_id: user_id!("@rantanplan:server.name").to_owned(),
rule_id: owned_user_id!("@rantanplan:server.name"),
};
set.sender.insert(sender);
@ -1598,7 +1598,7 @@ mod tests {
actions: vec![Action::SetTweak(Tweak::Highlight(true))],
default: false,
enabled: true,
rule_id: room_id!("!dm:server.name").to_owned(),
rule_id: owned_room_id!("!dm:server.name"),
};
set.room.insert(room);
@ -1671,9 +1671,9 @@ mod tests {
let set = Ruleset::server_default(user_id!("@jolly_jumper:server.name"));
let context = &PushConditionRoomCtx {
room_id: room_id!("!far_west:server.name").to_owned(),
room_id: owned_room_id!("!far_west:server.name"),
member_count: uint!(100),
user_id: user_id!("@jj:server.name").to_owned(),
user_id: owned_user_id!("@jj:server.name"),
user_display_name: "Jolly Jumper".into(),
users_power_levels: BTreeMap::new(),
default_power_level: int!(50),
@ -1783,9 +1783,9 @@ mod tests {
let set = Ruleset::server_default(user_id!("@jolly_jumper:server.name"));
let context = &PushConditionRoomCtx {
room_id: room_id!("!far_west:server.name").to_owned(),
room_id: owned_room_id!("!far_west:server.name"),
member_count: uint!(100),
user_id: user_id!("@jj:server.name").to_owned(),
user_id: owned_user_id!("@jj:server.name"),
user_display_name: "Jolly Jumper".into(),
users_power_levels: BTreeMap::new(),
default_power_level: int!(50),

View File

@ -451,7 +451,10 @@ mod tests {
};
use super::{FlattenedJson, PushCondition, PushConditionRoomCtx, RoomMemberCountIs, StrExt};
use crate::{power_levels::NotificationPowerLevels, room_id, serde::Raw, user_id, OwnedUserId};
use crate::{
owned_room_id, owned_user_id, power_levels::NotificationPowerLevels, serde::Raw,
OwnedUserId,
};
#[test]
fn serialize_event_match_condition() {
@ -639,7 +642,7 @@ mod tests {
}
fn sender() -> OwnedUserId {
user_id!("@worthy_whale:server.name").to_owned()
owned_user_id!("@worthy_whale:server.name")
}
fn push_context() -> PushConditionRoomCtx {
@ -647,9 +650,9 @@ mod tests {
users_power_levels.insert(sender(), int!(25));
PushConditionRoomCtx {
room_id: room_id!("!room:server.name").to_owned(),
room_id: owned_room_id!("!room:server.name"),
member_count: uint!(3),
user_id: user_id!("@gorilla:server.name").to_owned(),
user_id: owned_user_id!("@gorilla:server.name"),
user_display_name: "Groovy Gorilla".into(),
users_power_levels,
default_power_level: int!(50),
@ -768,9 +771,9 @@ mod tests {
let context_not_matching = push_context();
let context_matching = PushConditionRoomCtx {
room_id: room_id!("!room:server.name").to_owned(),
room_id: owned_room_id!("!room:server.name"),
member_count: uint!(3),
user_id: user_id!("@gorilla:server.name").to_owned(),
user_id: owned_user_id!("@gorilla:server.name"),
user_display_name: "Groovy Gorilla".into(),
users_power_levels: context_not_matching.users_power_levels.clone(),
default_power_level: int!(50),

View File

@ -6,7 +6,7 @@ use ruma_common::{
request, response, IncomingRequest as _, MatrixVersion, Metadata, OutgoingRequest as _,
OutgoingRequestAppserviceExt, SendAccessToken,
},
metadata, user_id, OwnedUserId,
metadata, owned_user_id, user_id, OwnedUserId,
};
const METADATA: Metadata = metadata! {
@ -59,7 +59,7 @@ fn request_serde() {
q1: "query_param_special_chars %/&@!".to_owned(),
q2: 55,
bar: "barVal".to_owned(),
user: user_id!("@bazme:ruma.io").to_owned(),
user: owned_user_id!("@bazme:ruma.io"),
};
let http_req = req
@ -88,7 +88,7 @@ fn invalid_uri_should_not_panic() {
q1: "query_param_special_chars %/&@!".to_owned(),
q2: 55,
bar: "barVal".to_owned(),
user: user_id!("@bazme:ruma.io").to_owned(),
user: owned_user_id!("@bazme:ruma.io"),
};
let result = req.try_into_http_request::<Vec<u8>>(
@ -107,7 +107,7 @@ fn request_with_user_id_serde() {
q1: "query_param_special_chars %/&@!".to_owned(),
q2: 55,
bar: "barVal".to_owned(),
user: user_id!("@bazme:ruma.io").to_owned(),
user: owned_user_id!("@bazme:ruma.io"),
};
let user_id = user_id!("@_virtual_:ruma.io");
@ -135,7 +135,7 @@ mod without_query {
request, response, MatrixVersion, Metadata, OutgoingRequestAppserviceExt,
SendAccessToken,
},
metadata, user_id, OwnedUserId,
metadata, owned_user_id, user_id, OwnedUserId,
};
const METADATA: Metadata = metadata! {
@ -180,7 +180,7 @@ mod without_query {
hello: "hi".to_owned(),
world: "test".to_owned(),
bar: "barVal".to_owned(),
user: user_id!("@bazme:ruma.io").to_owned(),
user: owned_user_id!("@bazme:ruma.io"),
};
let user_id = user_id!("@_virtual_:ruma.io");

View File

@ -7,7 +7,6 @@ use js_int::uint;
#[cfg(feature = "unstable-msc3246")]
use ruma_common::events::audio::Amplitude;
use ruma_common::{
event_id,
events::{
audio::{AudioDetailsContentBlock, AudioEventContent},
file::{EncryptedContentInit, FileContentBlock},
@ -16,7 +15,7 @@ use ruma_common::{
room::{message::Relation, JsonWebKeyInit},
AnyMessageLikeEvent, MessageLikeEvent,
},
mxc_uri,
mxc_uri, owned_event_id,
serde::{Base64, CanBeEmpty},
MilliSecondsSinceUnixEpoch,
};
@ -122,7 +121,7 @@ fn event_serialization() {
content.file.size = Some(uint!(897_774));
content.audio_details = Some(AudioDetailsContentBlock::new(Duration::from_secs(123)));
content.relates_to = Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$replyevent:example.com").to_owned()),
in_reply_to: InReplyTo::new(owned_event_id!("$replyevent:example.com")),
});
assert_eq!(

View File

@ -1,6 +1,5 @@
use assert_matches2::assert_matches;
use ruma_common::{
device_id, event_id,
events::{
relation::{InReplyTo, Reference, Thread},
room::encrypted::{
@ -8,6 +7,7 @@ use ruma_common::{
RoomEncryptedEventContent,
},
},
owned_device_id, owned_event_id,
};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
@ -22,7 +22,7 @@ fn encrypted_scheme() -> EncryptedEventScheme {
lDl5mzVO3tPnJMKZ0hn+AF"
.to_owned(),
sender_key: "aV9BpqYFqJpKYmgERyGv/6QyKMcgLqxM05V0gvzg9Yk".to_owned(),
device_id: device_id!("DEVICE").to_owned(),
device_id: owned_device_id!("DEVICE"),
session_id: "IkwqWxT2zy3DI1E/zM2Wq+CE8tr3eEpsxsVGjGrMPdw".to_owned(),
}
.into(),
@ -86,9 +86,7 @@ fn content_no_relation_deserialization() {
fn content_reply_serialization() {
let content = RoomEncryptedEventContent::new(
encrypted_scheme(),
Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$replied_to_event").to_owned()),
}),
Some(Relation::Reply { in_reply_to: InReplyTo::new(owned_event_id!("$replied_to_event")) }),
);
assert_eq!(
@ -155,7 +153,7 @@ fn content_reply_deserialization() {
fn content_replacement_serialization() {
let content = RoomEncryptedEventContent::new(
encrypted_scheme(),
Some(Relation::Replacement(Replacement::new(event_id!("$replaced_event").to_owned()))),
Some(Relation::Replacement(Replacement::new(owned_event_id!("$replaced_event")))),
);
assert_eq!(
@ -220,7 +218,7 @@ fn content_replacement_deserialization() {
fn content_reference_serialization() {
let content = RoomEncryptedEventContent::new(
encrypted_scheme(),
Some(Relation::Reference(Reference::new(event_id!("$referenced_event").to_owned()))),
Some(Relation::Reference(Reference::new(owned_event_id!("$referenced_event")))),
);
assert_eq!(
@ -286,8 +284,8 @@ fn content_thread_serialization() {
let content = RoomEncryptedEventContent::new(
encrypted_scheme(),
Some(Relation::Thread(Thread::plain(
event_id!("$thread_root").to_owned(),
event_id!("$prev_event").to_owned(),
owned_event_id!("$thread_root"),
owned_event_id!("$prev_event"),
))),
);
@ -365,7 +363,7 @@ fn content_annotation_serialization() {
let content = RoomEncryptedEventContent::new(
encrypted_scheme(),
Some(Relation::Annotation(Annotation::new(
event_id!("$annotated_event").to_owned(),
owned_event_id!("$annotated_event"),
"some_key".to_owned(),
))),
);

View File

@ -1,7 +1,10 @@
use assert_matches2::assert_matches;
use js_int::uint;
use maplit::btreemap;
use ruma_common::{event_id, events::receipt::ReceiptType, user_id, MilliSecondsSinceUnixEpoch};
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::{
@ -12,7 +15,7 @@ use ruma_common::events::{
#[test]
fn ephemeral_serialize_typing() {
let content = TypingEventContent::new(vec![user_id!("@carl:example.com").to_owned()]);
let content = TypingEventContent::new(vec![owned_user_id!("@carl:example.com")]);
let actual = to_json_value(&content).unwrap();
let expected = json!({
@ -43,8 +46,8 @@ fn deserialize_ephemeral_typing() {
#[test]
fn ephemeral_serialize_receipt() {
let event_id = event_id!("$h29iv0s8:example.com").to_owned();
let user_id = user_id!("@carl:example.com").to_owned();
let event_id = owned_event_id!("$h29iv0s8:example.com");
let user_id = owned_user_id!("@carl:example.com");
let content = ReceiptEventContent(btreemap! {
event_id => btreemap! {

View File

@ -3,7 +3,6 @@
use assert_matches2::assert_matches;
use js_int::uint;
use ruma_common::{
event_id,
events::{
file::{EncryptedContentInit, FileEventContent},
message::TextContentBlock,
@ -11,7 +10,7 @@ use ruma_common::{
room::{message::Relation, JsonWebKeyInit},
AnyMessageLikeEvent, MessageLikeEvent,
},
mxc_uri,
mxc_uri, owned_event_id,
serde::{Base64, CanBeEmpty},
MilliSecondsSinceUnixEpoch,
};
@ -101,7 +100,7 @@ fn file_event_serialization() {
content.file.mimetype = Some("text/plain".to_owned());
content.file.size = Some(uint!(774));
content.relates_to = Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$replyevent:example.com").to_owned()),
in_reply_to: InReplyTo::new(owned_event_id!("$replyevent:example.com")),
});
assert_eq!(

View File

@ -3,7 +3,6 @@
use assert_matches2::assert_matches;
use js_int::uint;
use ruma_common::{
event_id,
events::{
file::{CaptionContentBlock, EncryptedContentInit, FileContentBlock},
image::{
@ -15,7 +14,7 @@ use ruma_common::{
room::{message::Relation, JsonWebKeyInit},
AnyMessageLikeEvent, MessageLikeEvent,
},
mxc_uri,
mxc_uri, owned_event_id,
serde::{Base64, CanBeEmpty},
MilliSecondsSinceUnixEpoch,
};
@ -123,7 +122,7 @@ fn image_event_serialization() {
content.thumbnail = vec![thumbnail].into();
content.caption = Some(CaptionContentBlock::plain("This is my house"));
content.relates_to = Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$replyevent:example.com").to_owned()),
in_reply_to: InReplyTo::new(owned_event_id!("$replyevent:example.com")),
});
assert_eq!(

View File

@ -12,7 +12,7 @@ use ruma_common::{
room::message::Relation,
AnyMessageLikeEvent, MessageLikeEvent,
},
room_id,
owned_event_id, room_id,
serde::CanBeEmpty,
user_id, MilliSecondsSinceUnixEpoch,
};
@ -57,7 +57,7 @@ fn event_serialization() {
{
ts: Some(MilliSecondsSinceUnixEpoch(uint!(1_636_829_458))),
relates_to: Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$replyevent:example.com").to_owned()),
in_reply_to: InReplyTo::new(owned_event_id!("$replyevent:example.com")),
}),
}
);

View File

@ -4,7 +4,6 @@ use assert_matches2::assert_matches;
use assign::assign;
use js_int::uint;
use ruma_common::{
event_id,
events::{
emote::EmoteEventContent,
message::{MessageEventContent, TextContentBlock, TextRepresentation},
@ -12,6 +11,7 @@ use ruma_common::{
room::message::Relation,
AnyMessageLikeEvent, MessageLikeEvent,
},
owned_event_id,
serde::CanBeEmpty,
MilliSecondsSinceUnixEpoch,
};
@ -134,7 +134,7 @@ fn relates_to_content_serialization() {
assign!(MessageEventContent::plain("> <@test:example.com> test\n\ntest reply"), {
relates_to: Some(Relation::Reply {
in_reply_to: InReplyTo::new(
event_id!("$15827405538098VGFWH:example.com").to_owned(),
owned_event_id!("$15827405538098VGFWH:example.com"),
),
}),
});

View File

@ -9,7 +9,8 @@ use ruma_common::{
pdu::{EventHash, Pdu, RoomV1Pdu, RoomV3Pdu},
TimelineEventType,
},
room_id, server_name, server_signing_key_id, user_id, MilliSecondsSinceUnixEpoch,
owned_event_id, owned_room_id, owned_server_signing_key_id, owned_user_id, server_name,
MilliSecondsSinceUnixEpoch,
};
use serde_json::{
from_value as from_json_value, json, to_value as to_json_value,
@ -21,7 +22,7 @@ fn serialize_pdu_as_v1() {
let mut signatures = BTreeMap::new();
let mut inner_signature = BTreeMap::new();
inner_signature.insert(
server_signing_key_id!("ed25519:key_version").to_owned(),
owned_server_signing_key_id!("ed25519:key_version"),
"86BytesOfSignatureOfTheRedactedEvent".into(),
);
signatures.insert(server_name!("example.com").to_owned(), inner_signature);
@ -30,23 +31,23 @@ fn serialize_pdu_as_v1() {
unsigned.insert("somekey".into(), to_raw_json_value(&json!({ "a": 456 })).unwrap());
let v1_pdu = RoomV1Pdu {
room_id: room_id!("!n8f893n9:example.com").to_owned(),
event_id: event_id!("$somejoinevent:matrix.org").to_owned(),
sender: user_id!("@sender:example.com").to_owned(),
room_id: owned_room_id!("!n8f893n9:example.com"),
event_id: owned_event_id!("$somejoinevent:matrix.org"),
sender: owned_user_id!("@sender:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(1_592_050_773_658_u64.try_into().unwrap()),
kind: TimelineEventType::RoomPowerLevels,
content: to_raw_json_value(&json!({ "testing": 123 })).unwrap(),
state_key: Some("state".into()),
prev_events: vec![(
event_id!("$previousevent:matrix.org").to_owned(),
owned_event_id!("$previousevent:matrix.org"),
EventHash::new("123567".into()),
)],
depth: uint!(2),
auth_events: vec![(
event_id!("$someauthevent:matrix.org").to_owned(),
owned_event_id!("$someauthevent:matrix.org"),
EventHash::new("21389CFEDABC".into()),
)],
redacts: Some(event_id!("$9654:matrix.org").to_owned()),
redacts: Some(owned_event_id!("$9654:matrix.org")),
unsigned,
hashes: EventHash::new("1233543bABACDEF".into()),
signatures,
@ -86,7 +87,7 @@ fn serialize_pdu_as_v3() {
let mut signatures = BTreeMap::new();
let mut inner_signature = BTreeMap::new();
inner_signature.insert(
server_signing_key_id!("ed25519:key_version").to_owned(),
owned_server_signing_key_id!("ed25519:key_version"),
"86BytesOfSignatureOfTheRedactedEvent".into(),
);
signatures.insert(server_name!("example.com").to_owned(), inner_signature);
@ -95,16 +96,16 @@ fn serialize_pdu_as_v3() {
unsigned.insert("somekey".into(), to_raw_json_value(&json!({ "a": 456 })).unwrap());
let v3_pdu = RoomV3Pdu {
room_id: room_id!("!n8f893n9:example.com").to_owned(),
sender: user_id!("@sender:example.com").to_owned(),
room_id: owned_room_id!("!n8f893n9:example.com"),
sender: owned_user_id!("@sender:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(1_592_050_773_658_u64.try_into().unwrap()),
kind: TimelineEventType::RoomPowerLevels,
content: to_raw_json_value(&json!({ "testing": 123 })).unwrap(),
state_key: Some("state".into()),
prev_events: vec![event_id!("$previousevent:matrix.org").to_owned()],
prev_events: vec![owned_event_id!("$previousevent:matrix.org")],
depth: uint!(2),
auth_events: vec![event_id!("$someauthevent:matrix.org").to_owned()],
redacts: Some(event_id!("$9654:matrix.org").to_owned()),
auth_events: vec![owned_event_id!("$someauthevent:matrix.org")],
redacts: Some(owned_event_id!("$9654:matrix.org")),
unsigned,
hashes: EventHash::new("1233543bABACDEF".into()),
signatures,

View File

@ -5,7 +5,6 @@ use std::collections::BTreeMap;
use assert_matches2::assert_matches;
use js_int::uint;
use ruma_common::{
event_id,
events::{
message::TextContentBlock,
poll::{
@ -19,6 +18,7 @@ use ruma_common::{
relation::Reference,
AnyMessageLikeEvent, MessageLikeEvent,
},
owned_event_id,
};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
@ -197,7 +197,7 @@ fn start_event_deserialization() {
fn response_content_serialization() {
let event_content = PollResponseEventContent::new(
vec!["my-answer".to_owned()].into(),
event_id!("$related_event:notareal.hs").to_owned(),
owned_event_id!("$related_event:notareal.hs"),
);
assert_eq!(
@ -216,7 +216,7 @@ fn response_content_serialization() {
fn response_event_serialization() {
let content = PollResponseEventContent::new(
vec!["first-answer".to_owned(), "second-answer".to_owned()].into(),
event_id!("$related_event:notareal.hs").to_owned(),
owned_event_id!("$related_event:notareal.hs"),
);
assert_eq!(
@ -264,7 +264,7 @@ fn response_event_deserialization() {
fn end_content_serialization() {
let event_content = PollEndEventContent::with_plain_text(
"The poll has closed. Top answer: Amazing!",
event_id!("$related_event:notareal.hs").to_owned(),
owned_event_id!("$related_event:notareal.hs"),
);
assert_eq!(
@ -285,7 +285,7 @@ fn end_content_serialization() {
fn end_event_serialization() {
let mut content = PollEndEventContent::with_plain_text(
"The poll has closed. Top answer: Amazing!",
event_id!("$related_event:notareal.hs").to_owned(),
owned_event_id!("$related_event:notareal.hs"),
);
content.poll_results = Some(
BTreeMap::from([

View File

@ -172,10 +172,10 @@ fn redact_method_properly_redacts() {
let redaction = OriginalSyncRoomRedactionEvent {
content: RoomRedactionEventContent::with_reason("redacted because".into()),
redacts: event_id!("$143273582443PhrSn:example.com").to_owned(),
event_id: event_id!("$h29iv0s8:example.com").to_owned(),
redacts: owned_event_id!("$143273582443PhrSn:example.com"),
event_id: owned_event_id!("$h29iv0s8:example.com"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)),
sender: user_id!("@carl:example.com").to_owned(),
sender: owned_user_id!("@carl:example.com"),
unsigned: MessageLikeUnsigned::default(),
};

View File

@ -1,11 +1,11 @@
use assert_matches2::assert_matches;
use assign::assign;
use ruma_common::{
event_id,
events::{
relation::{InReplyTo, Replacement, Thread},
room::message::{MessageType, Relation, RoomMessageEventContent},
},
owned_event_id,
};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
@ -35,7 +35,7 @@ fn reply_deserialize() {
#[test]
fn reply_serialize() {
let content = assign!(RoomMessageEventContent::text_plain("This is a reply"), {
relates_to: Some(Relation::Reply { in_reply_to: InReplyTo::new(event_id!("$1598361704261elfgc").to_owned()) }),
relates_to: Some(Relation::Reply { in_reply_to: InReplyTo::new(owned_event_id!("$1598361704261elfgc")) }),
});
assert_eq!(
@ -59,7 +59,7 @@ fn replacement_serialize() {
{
relates_to: Some(Relation::Replacement(
Replacement::new(
event_id!("$1598361704261elfgc").to_owned(),
owned_event_id!("$1598361704261elfgc"),
RoomMessageEventContent::text_plain("This is the new content.").into(),
)
))
@ -118,8 +118,8 @@ fn thread_plain_serialize() {
{
relates_to: Some(Relation::Thread(
Thread::plain(
event_id!("$1598361704261elfgc").to_owned(),
event_id!("$latesteventid").to_owned(),
owned_event_id!("$1598361704261elfgc"),
owned_event_id!("$latesteventid"),
),
)),
}
@ -149,8 +149,8 @@ fn thread_reply_serialize() {
{
relates_to: Some(Relation::Thread(
Thread::reply(
event_id!("$1598361704261elfgc").to_owned(),
event_id!("$repliedtoeventid").to_owned(),
owned_event_id!("$1598361704261elfgc"),
owned_event_id!("$repliedtoeventid"),
),
)),
}

View File

@ -3,7 +3,6 @@ use std::borrow::Cow;
use assert_matches2::assert_matches;
use js_int::uint;
use ruma_common::{
event_id,
events::{
key::verification::VerificationMethod,
room::{
@ -17,7 +16,7 @@ use ruma_common::{
},
MessageLikeUnsigned,
},
mxc_uri, room_id,
mxc_uri, owned_event_id, owned_room_id, owned_user_id,
serde::Base64,
user_id, MilliSecondsSinceUnixEpoch, OwnedDeviceId,
};
@ -224,7 +223,7 @@ fn verification_request_msgtype_deserialization() {
#[test]
fn verification_request_msgtype_serialization() {
let user_id = user_id!("@example2:localhost").to_owned();
let user_id = owned_user_id!("@example2:localhost");
let device_id: OwnedDeviceId = "XOWLHHFSWM".into();
let body = "@example:localhost is requesting to verify your key, ...".to_owned();
@ -260,10 +259,10 @@ fn content_deserialization_failure() {
fn escape_tags_in_plain_reply_body() {
let first_message = OriginalRoomMessageEvent {
content: RoomMessageEventContent::text_plain("Usage: cp <source> <destination>"),
event_id: event_id!("$143273582443PhrSn:example.org").to_owned(),
event_id: owned_event_id!("$143273582443PhrSn:example.org"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(10_000)),
room_id: room_id!("!testroomid:example.org").to_owned(),
sender: user_id!("@user:example.org").to_owned(),
room_id: owned_room_id!("!testroomid:example.org"),
sender: owned_user_id!("@user:example.org"),
unsigned: MessageLikeUnsigned::default(),
};
let second_message = RoomMessageEventContent::text_plain("Usage: rm <path>")
@ -313,10 +312,10 @@ fn reply_sanitize() {
"# This is the first message",
"<h1>This is the first message</h1>",
),
event_id: event_id!("$143273582443PhrSn:example.org").to_owned(),
event_id: owned_event_id!("$143273582443PhrSn:example.org"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(10_000)),
room_id: room_id!("!testroomid:example.org").to_owned(),
sender: user_id!("@user:example.org").to_owned(),
room_id: owned_room_id!("!testroomid:example.org"),
sender: owned_user_id!("@user:example.org"),
unsigned: MessageLikeUnsigned::default(),
};
let second_message = OriginalRoomMessageEvent {
@ -325,10 +324,10 @@ fn reply_sanitize() {
"This is the <em>second</em> message",
)
.make_reply_to(&first_message, ForwardThread::Yes),
event_id: event_id!("$143273582443PhrSn:example.org").to_owned(),
event_id: owned_event_id!("$143273582443PhrSn:example.org"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(10_000)),
room_id: room_id!("!testroomid:example.org").to_owned(),
sender: user_id!("@user:example.org").to_owned(),
room_id: owned_room_id!("!testroomid:example.org"),
sender: owned_user_id!("@user:example.org"),
unsigned: MessageLikeUnsigned::default(),
};
let final_reply = RoomMessageEventContent::text_html(
@ -406,7 +405,7 @@ fn make_replacement_no_reply() {
"This is _an edited_ message.",
"This is <em>an edited</em> message.",
);
let event_id = event_id!("$143273582443PhrSn:example.org").to_owned();
let event_id = owned_event_id!("$143273582443PhrSn:example.org");
let content = content.make_replacement(event_id, None);
@ -426,10 +425,10 @@ fn make_replacement_with_reply() {
"# This is the first message",
"<h1>This is the first message</h1>",
),
event_id: event_id!("$143273582443PhrSn:example.org").to_owned(),
event_id: owned_event_id!("$143273582443PhrSn:example.org"),
origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(10_000)),
room_id: room_id!("!testroomid:example.org").to_owned(),
sender: user_id!("@user:example.org").to_owned(),
room_id: owned_room_id!("!testroomid:example.org"),
sender: owned_user_id!("@user:example.org"),
unsigned: MessageLikeUnsigned::default(),
};
@ -437,7 +436,7 @@ fn make_replacement_with_reply() {
"This is _an edited_ reply.",
"This is <em>an edited</em> reply.",
);
let event_id = event_id!("$143273582443PhrSn:example.org").to_owned();
let event_id = owned_event_id!("$143273582443PhrSn:example.org");
let content = content.make_replacement(event_id, Some(&replied_to_message));

View File

@ -1,5 +1,5 @@
use ruma_common::{
events::room_key::ToDeviceRoomKeyEventContent, room_id, EventEncryptionAlgorithm,
events::room_key::ToDeviceRoomKeyEventContent, owned_room_id, EventEncryptionAlgorithm,
};
use serde_json::{json, to_value as to_json_value};
@ -7,7 +7,7 @@ use serde_json::{json, to_value as to_json_value};
fn serialization() {
let content = ToDeviceRoomKeyEventContent::new(
EventEncryptionAlgorithm::MegolmV1AesSha2,
room_id!("!testroomid:example.org").to_owned(),
owned_room_id!("!testroomid:example.org"),
"SessId".into(),
"SessKey".into(),
);

View File

@ -5,7 +5,6 @@ use std::time::Duration;
use assert_matches2::assert_matches;
use js_int::uint;
use ruma_common::{
event_id,
events::{
file::{CaptionContentBlock, EncryptedContentInit, FileContentBlock},
image::{Thumbnail, ThumbnailFileContentBlock, ThumbnailImageDetailsContentBlock},
@ -15,7 +14,7 @@ use ruma_common::{
video::{VideoDetailsContentBlock, VideoEventContent},
AnyMessageLikeEvent, MessageLikeEvent,
},
mxc_uri,
mxc_uri, owned_event_id,
serde::{Base64, CanBeEmpty},
MilliSecondsSinceUnixEpoch,
};
@ -128,7 +127,7 @@ fn event_serialization() {
content.thumbnail = vec![thumbnail].into();
content.caption = Some(CaptionContentBlock::plain("This is my awesome vintage lava lamp"));
content.relates_to = Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$replyevent:example.com").to_owned()),
in_reply_to: InReplyTo::new(owned_event_id!("$replyevent:example.com")),
});
assert_eq!(

View File

@ -5,7 +5,6 @@ use std::time::Duration;
use assert_matches2::assert_matches;
use js_int::uint;
use ruma_common::{
event_id,
events::{
audio::Amplitude,
file::FileContentBlock,
@ -14,7 +13,7 @@ use ruma_common::{
voice::{VoiceAudioDetailsContentBlock, VoiceEventContent},
AnyMessageLikeEvent, MessageLikeEvent,
},
mxc_uri,
mxc_uri, owned_event_id,
serde::CanBeEmpty,
MilliSecondsSinceUnixEpoch,
};
@ -37,7 +36,7 @@ fn event_serialization() {
content.file.mimetype = Some("audio/opus".to_owned());
content.file.size = Some(uint!(897_774));
content.relates_to = Some(Relation::Reply {
in_reply_to: InReplyTo::new(event_id!("$replyevent:example.com").to_owned()),
in_reply_to: InReplyTo::new(owned_event_id!("$replyevent:example.com")),
});
assert_eq!(

View File

@ -1,10 +1,10 @@
use assert_matches2::assert_matches;
use ruma_common::{
event_id,
events::{
relation::InReplyTo,
room::message::{MessageType, Relation, RoomMessageEventContent},
},
owned_event_id,
};
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
@ -12,7 +12,7 @@ use serde_json::{from_value as from_json_value, json, to_value as to_json_value}
fn serialize_room_message_content_without_relation() {
let mut content = RoomMessageEventContent::text_plain("Hello, world!");
content.relates_to =
Some(Relation::Reply { in_reply_to: InReplyTo::new(event_id!("$eventId").to_owned()) });
Some(Relation::Reply { in_reply_to: InReplyTo::new(owned_event_id!("$eventId")) });
let without_relation = MessageType::from(content);
assert_eq!(
@ -39,7 +39,7 @@ fn deserialize_room_message_content_without_relation() {
fn convert_room_message_content_without_relation_to_full() {
let mut content = RoomMessageEventContent::text_plain("Hello, world!");
content.relates_to =
Some(Relation::Reply { in_reply_to: InReplyTo::new(event_id!("$eventId").to_owned()) });
Some(Relation::Reply { in_reply_to: InReplyTo::new(owned_event_id!("$eventId")) });
let new_content = RoomMessageEventContent::from(MessageType::from(content));
assert_matches!(

View File

@ -73,7 +73,7 @@ where
mod tests {
use std::collections::BTreeMap;
use ruma_common::{event_id, OwnedEventId};
use ruma_common::{event_id, owned_event_id, OwnedEventId};
use serde_json::{json, value::Serializer as JsonSerializer};
use super::{deserialize, serialize};
@ -81,10 +81,8 @@ mod tests {
#[test]
fn serialize_error() {
let mut response: BTreeMap<OwnedEventId, Result<(), String>> = BTreeMap::new();
response.insert(
event_id!("$someevent:matrix.org").to_owned(),
Err("Some processing error.".into()),
);
response
.insert(owned_event_id!("$someevent:matrix.org"), Err("Some processing error.".into()));
let serialized = serialize(&response, JsonSerializer).unwrap();
let json = json!({
@ -96,7 +94,7 @@ mod tests {
#[test]
fn serialize_ok() {
let mut response: BTreeMap<OwnedEventId, Result<(), String>> = BTreeMap::new();
response.insert(event_id!("$someevent:matrix.org").to_owned(), Ok(()));
response.insert(owned_event_id!("$someevent:matrix.org"), Ok(()));
let serialized = serialize(&response, serde_json::value::Serializer).unwrap();
let json = json!({

View File

@ -376,8 +376,8 @@ pub mod v1 {
mod tests {
use js_int::uint;
use ruma_common::{
event_id, events::TimelineEventType, room_alias_id, room_id, user_id,
SecondsSinceUnixEpoch,
events::TimelineEventType, owned_event_id, owned_room_alias_id, owned_room_id,
owned_user_id, SecondsSinceUnixEpoch,
};
use serde_json::{
from_value as from_json_value, json, to_value as to_json_value, Value as JsonValue,
@ -413,10 +413,10 @@ pub mod v1 {
]
});
let eid = event_id!("$3957tyerfgewrf384").to_owned();
let rid = room_id!("!slw48wfj34rtnrf:example.com").to_owned();
let uid = user_id!("@exampleuser:matrix.org").to_owned();
let alias = room_alias_id!("#exampleroom:matrix.org").to_owned();
let eid = owned_event_id!("$3957tyerfgewrf384");
let rid = owned_room_id!("!slw48wfj34rtnrf:example.com");
let uid = owned_user_id!("@exampleuser:matrix.org");
let alias = owned_room_alias_id!("#exampleroom:matrix.org");
let count = NotificationCounts { unread: uint!(2), ..NotificationCounts::default() };