diff --git a/ruma-events/Cargo.toml b/ruma-events/Cargo.toml index e3328d6a94..3393a6a55a 100644 --- a/ruma-events/Cargo.toml +++ b/ruma-events/Cargo.toml @@ -35,3 +35,6 @@ unstable-exhaustive-types = [] [[bench]] name = "event_deserialize" harness = false + +[features] +unstable-pre-spec = [] diff --git a/ruma-events/src/pdu.rs b/ruma-events/src/pdu.rs index 746aa1fab2..7c4c8889e8 100644 --- a/ruma-events/src/pdu.rs +++ b/ruma-events/src/pdu.rs @@ -38,6 +38,7 @@ pub struct RoomV1Pdu { /// The user id of the user who sent this event. pub sender: UserId, + #[cfg(not(feature = "unstable-pre-spec"))] /// The `server_name` of the homeserver that created this event. pub origin: String, @@ -96,6 +97,7 @@ pub struct RoomV3Pdu { /// The user id of the user who sent this event. pub sender: UserId, + #[cfg(not(feature = "unstable-pre-spec"))] /// The `server_name` of the homeserver that created this event. pub origin: String, @@ -172,6 +174,7 @@ pub struct RoomV1PduStub { /// The user id of the user who sent this event. pub sender: UserId, + #[cfg(not(feature = "unstable-pre-spec"))] /// The `server_name` of the homeserver that created this event. pub origin: String, @@ -226,6 +229,7 @@ impl RoomV1PduStub { event_id, room_id, sender: self.sender, + #[cfg(not(feature = "unstable-pre-spec"))] origin: self.origin, origin_server_ts: self.origin_server_ts, kind: self.kind, @@ -248,6 +252,7 @@ pub struct RoomV3PduStub { /// The user id of the user who sent this event. pub sender: UserId, + #[cfg(not(feature = "unstable-pre-spec"))] /// The `server_name` of the homeserver that created this event. pub origin: String, @@ -301,6 +306,7 @@ impl RoomV3PduStub { RoomV3Pdu { room_id, sender: self.sender, + #[cfg(not(feature = "unstable-pre-spec"))] origin: self.origin, origin_server_ts: self.origin_server_ts, kind: self.kind, diff --git a/ruma-events/tests/pdu.rs b/ruma-events/tests/pdu.rs index 26d23f5494..3c0c7a6daf 100644 --- a/ruma-events/tests/pdu.rs +++ b/ruma-events/tests/pdu.rs @@ -11,6 +11,7 @@ use ruma_events::{ use ruma_identifiers::{event_id, room_id, server_key_id, server_name, user_id}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn serialize_stub_as_v1() { let mut signatures = BTreeMap::new(); @@ -74,6 +75,7 @@ fn serialize_stub_as_v1() { assert_eq!(to_json_value(&pdu_stub).unwrap(), json); } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn serialize_stub_as_v3() { let mut signatures = BTreeMap::new(); @@ -127,6 +129,7 @@ fn serialize_stub_as_v3() { assert_eq!(to_json_value(&pdu_stub).unwrap(), json); } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn deserialize_stub_as_v1() { let json = json!({ @@ -184,6 +187,7 @@ fn deserialize_stub_as_v1() { } } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn deserialize_stub_as_v3() { let json = json!({ @@ -227,6 +231,7 @@ fn deserialize_stub_as_v3() { } } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn serialize_pdu_as_v1() { let mut signatures = BTreeMap::new(); @@ -294,6 +299,7 @@ fn serialize_pdu_as_v1() { assert_eq!(to_json_value(&pdu).unwrap(), json); } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn serialize_pdu_as_v3() { let mut signatures = BTreeMap::new(); @@ -349,6 +355,7 @@ fn serialize_pdu_as_v3() { assert_eq!(to_json_value(&pdu_stub).unwrap(), json); } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn test_deserialize_pdu_as_v1() { let json = json!({ @@ -408,6 +415,7 @@ fn test_deserialize_pdu_as_v1() { } } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn deserialize_pdu_as_v3() { let json = json!({ @@ -452,6 +460,7 @@ fn deserialize_pdu_as_v3() { } } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn convert_v1_stub_to_pdu() { let mut signatures = BTreeMap::new(); @@ -528,6 +537,7 @@ fn convert_v1_stub_to_pdu() { ); } +#[cfg(not(feature = "unstable-pre-spec"))] #[test] fn convert_v3_stub_to_pdu() { let mut signatures = BTreeMap::new(); diff --git a/ruma-federation-api/src/membership/create_join_event.rs b/ruma-federation-api/src/membership/create_join_event.rs index 5288ee8c31..04809bfaa5 100644 --- a/ruma-federation-api/src/membership/create_join_event.rs +++ b/ruma-federation-api/src/membership/create_join_event.rs @@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct RoomState { + #[cfg(not(feature = "unstable-pre-spec"))] /// The resident server's DNS name. pub origin: String, diff --git a/ruma-federation-api/src/serde/room_state.rs b/ruma-federation-api/src/serde/room_state.rs index ae9c94a830..af29d83ed6 100644 --- a/ruma-federation-api/src/serde/room_state.rs +++ b/ruma-federation-api/src/serde/room_state.rs @@ -59,6 +59,7 @@ impl<'de> Visitor<'de> for RoomStateVisitor { } } +#[cfg(not(feature = "unstable-pre-spec"))] #[cfg(test)] mod tests { use matches::assert_matches; @@ -142,7 +143,6 @@ mod tests { RoomState { origin, auth_chain, state } if origin == "" && auth_chain.is_empty() - && state.is_empty() ); } }