diff --git a/crates/ruma-events/Cargo.toml b/crates/ruma-events/Cargo.toml index c156336f..5f707dd3 100644 --- a/crates/ruma-events/Cargo.toml +++ b/crates/ruma-events/Cargo.toml @@ -21,8 +21,7 @@ markdown = ["pulldown-cmark"] unstable-exhaustive-types = [] unstable-pdu = [] -unstable-pre-spec = ["unstable-spec"] -unstable-spec = [] +unstable-pre-spec = [] [dependencies] criterion = { version = "0.3.3", optional = true } diff --git a/crates/ruma-events/src/enums.rs b/crates/ruma-events/src/enums.rs index 64c3a3c9..157da1be 100644 --- a/crates/ruma-events/src/enums.rs +++ b/crates/ruma-events/src/enums.rs @@ -74,9 +74,7 @@ event_enum! { "m.room.third_party_invite", "m.room.tombstone", "m.room.topic", - #[cfg(feature = "unstable-spec")] "m.space.child", - #[cfg(feature = "unstable-spec")] "m.space.parent", } diff --git a/crates/ruma-events/src/lib.rs b/crates/ruma-events/src/lib.rs index b4b191d6..ca7d308e 100644 --- a/crates/ruma-events/src/lib.rs +++ b/crates/ruma-events/src/lib.rs @@ -172,7 +172,6 @@ pub mod room; pub mod room_key; pub mod room_key_request; pub mod secret; -#[cfg(feature = "unstable-spec")] pub mod space; pub mod sticker; pub mod tag; diff --git a/crates/ruma-events/src/room/create.rs b/crates/ruma-events/src/room/create.rs index c336e84c..036b3687 100644 --- a/crates/ruma-events/src/room/create.rs +++ b/crates/ruma-events/src/room/create.rs @@ -4,11 +4,9 @@ use ruma_events_macros::EventContent; use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId}; -#[cfg(feature = "unstable-spec")] use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; -#[cfg(feature = "unstable-spec")] use crate::PrivOwnedStr; /// The content of an `m.room.create` event. @@ -47,7 +45,6 @@ pub struct RoomCreateEventContent { /// The room type. /// /// This is currently only used for spaces. - #[cfg(feature = "unstable-spec")] #[serde(skip_serializing_if = "Option::is_none", rename = "type")] pub room_type: Option, } @@ -60,7 +57,6 @@ impl RoomCreateEventContent { federate: true, room_version: default_room_version_id(), predecessor: None, - #[cfg(feature = "unstable-spec")] room_type: None, } } @@ -71,7 +67,6 @@ impl RoomCreateEventContent { /// This type can hold an arbitrary string. To check for formats that are not available as a /// documented variant here, use its string representation, obtained through `.as_str()`. #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] -#[cfg(feature = "unstable-spec")] #[non_exhaustive] pub enum RoomType { /// Defines the room as a space. @@ -83,7 +78,6 @@ pub enum RoomType { _Custom(PrivOwnedStr), } -#[cfg(feature = "unstable-spec")] impl RoomType { /// Creates a string slice from this `RoomType`. pub fn as_str(&self) -> &str { @@ -120,10 +114,7 @@ mod tests { use ruma_identifiers::{user_id, RoomVersionId}; use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; - use super::RoomCreateEventContent; - - #[cfg(feature = "unstable-spec")] - use super::RoomType; + use super::{RoomCreateEventContent, RoomType}; #[test] fn serialization() { @@ -132,7 +123,6 @@ mod tests { federate: false, room_version: RoomVersionId::V4, predecessor: None, - #[cfg(feature = "unstable-spec")] room_type: None, }; @@ -145,7 +135,6 @@ mod tests { assert_eq!(to_json_value(&content).unwrap(), json); } - #[cfg(feature = "unstable-spec")] #[test] fn space_serialization() { let content = RoomCreateEventContent { @@ -181,7 +170,6 @@ mod tests { federate: true, room_version: RoomVersionId::V4, predecessor: None, - #[cfg(feature = "unstable-spec")] room_type: None, } if creator == "@carl:example.com" ); diff --git a/crates/ruma-events/src/room/join_rules.rs b/crates/ruma-events/src/room/join_rules.rs index 1b2fe5e0..bd47d6c9 100644 --- a/crates/ruma-events/src/room/join_rules.rs +++ b/crates/ruma-events/src/room/join_rules.rs @@ -3,20 +3,14 @@ //! [`m.room.join_rules`]: https://spec.matrix.org/v1.1/client-server-api/#mroomjoin_rules use ruma_events_macros::EventContent; -#[cfg(feature = "unstable-spec")] use ruma_identifiers::RoomId; -#[cfg(feature = "unstable-spec")] use ruma_serde::from_raw_json_value; use serde::{ de::{Deserializer, Error}, Deserialize, Serialize, }; -use serde_json::value::RawValue as RawJsonValue; -#[cfg(feature = "unstable-spec")] -use serde_json::Value as JsonValue; -use std::borrow::Cow; -#[cfg(feature = "unstable-spec")] -use std::collections::BTreeMap; +use serde_json::{value::RawValue as RawJsonValue, Value as JsonValue}; +use std::{borrow::Cow, collections::BTreeMap}; use crate::PrivOwnedStr; @@ -41,7 +35,6 @@ impl RoomJoinRulesEventContent { /// Creates a new `RoomJoinRulesEventContent` with the restricted rule and the given set of /// allow rules. - #[cfg(feature = "unstable-spec")] pub fn restricted(allow: Vec) -> Self { Self { join_rule: JoinRule::Restricted(Restricted::new(allow)) } } @@ -80,7 +73,6 @@ pub enum JoinRule { /// Users can join the room if they are invited, or if they meet any of the conditions /// described in a set of [`AllowRule`]s. - #[cfg(feature = "unstable-spec")] #[serde(rename = "restricted")] Restricted(Restricted), @@ -100,7 +92,6 @@ impl JoinRule { JoinRule::Invite => "invite", JoinRule::Knock => "knock", JoinRule::Private => "private", - #[cfg(feature = "unstable-spec")] JoinRule::Restricted(_) => "restricted", JoinRule::Public => "public", JoinRule::_Custom(rule) => &rule.0, @@ -129,7 +120,6 @@ impl<'de> Deserialize<'de> for JoinRule { "invite" => Ok(Self::Invite), "knock" => Ok(Self::Knock), "private" => Ok(Self::Private), - #[cfg(feature = "unstable-spec")] "restricted" => from_raw_json_value(&json).map(Self::Restricted), "public" => Ok(Self::Public), _ => Ok(Self::_Custom(PrivOwnedStr(join_rule.into()))), @@ -138,7 +128,6 @@ impl<'de> Deserialize<'de> for JoinRule { } /// Configuration of the `Restricted` join rule. -#[cfg(feature = "unstable-spec")] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct Restricted { @@ -146,7 +135,6 @@ pub struct Restricted { allow: Vec, } -#[cfg(feature = "unstable-spec")] impl Restricted { /// Constructs a new rule set for restricted rooms with the given rules. pub fn new(allow: Vec) -> Self { @@ -155,7 +143,6 @@ impl Restricted { } /// An allow rule which defines a condition that allows joining a room. -#[cfg(feature = "unstable-spec")] #[derive(Clone, Debug, PartialEq, Eq, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[serde(tag = "type")] @@ -168,7 +155,6 @@ pub enum AllowRule { _Custom(CustomAllowRule), } -#[cfg(feature = "unstable-spec")] impl AllowRule { /// Constructs an `AllowRule` with membership of the room with the given id as its predicate. pub fn room_membership(room_id: Box) -> Self { @@ -177,7 +163,6 @@ impl AllowRule { } /// Allow rule which grants permission to join based on the membership of another room. -#[cfg(feature = "unstable-spec")] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct RoomMembership { @@ -185,7 +170,6 @@ pub struct RoomMembership { pub room_id: Box, } -#[cfg(feature = "unstable-spec")] impl RoomMembership { /// Constructs a new room membership rule for the given room id. pub fn new(room_id: Box) -> Self { @@ -193,7 +177,6 @@ impl RoomMembership { } } -#[cfg(feature = "unstable-spec")] #[doc(hidden)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] @@ -204,7 +187,6 @@ pub struct CustomAllowRule { extra: BTreeMap, } -#[cfg(feature = "unstable-spec")] impl<'de> Deserialize<'de> for AllowRule { fn deserialize(deserializer: D) -> Result where @@ -235,12 +217,9 @@ impl<'de> Deserialize<'de> for AllowRule { #[cfg(test)] mod tests { use matches::assert_matches; - #[cfg(feature = "unstable-spec")] use ruma_identifiers::room_id; - #[cfg(feature = "unstable-spec")] - use super::AllowRule; - use super::{JoinRule, RoomJoinRulesEventContent, SyncRoomJoinRulesEvent}; + use super::{AllowRule, JoinRule, RoomJoinRulesEventContent, SyncRoomJoinRulesEvent}; #[test] fn deserialize() { @@ -249,7 +228,6 @@ mod tests { assert_matches!(event, RoomJoinRulesEventContent { join_rule: JoinRule::Public }); } - #[cfg(feature = "unstable-spec")] #[test] fn deserialize_restricted() { let json = r#"{ diff --git a/crates/ruma-events/src/room/member.rs b/crates/ruma-events/src/room/member.rs index 45731466..bbde8657 100644 --- a/crates/ruma-events/src/room/member.rs +++ b/crates/ruma-events/src/room/member.rs @@ -98,7 +98,6 @@ pub struct RoomMemberEventContent { pub reason: Option, /// Arbitrarily chosen `UserId` (MxID) of a local user who can send an invite. - #[cfg(feature = "unstable-spec")] #[serde(rename = "join_authorised_via_users_server")] #[serde(skip_serializing_if = "Option::is_none")] pub join_authorized_via_users_server: Option>, @@ -116,7 +115,6 @@ impl RoomMemberEventContent { #[cfg(feature = "unstable-pre-spec")] blurhash: None, reason: None, - #[cfg(feature = "unstable-spec")] join_authorized_via_users_server: None, } } @@ -128,7 +126,6 @@ impl RedactContent for RoomMemberEventContent { fn redact(self, _version: &RoomVersionId) -> RedactedRoomMemberEventContent { RedactedRoomMemberEventContent { membership: self.membership, - #[cfg(feature = "unstable-spec")] join_authorized_via_users_server: match _version { RoomVersionId::V9 => self.join_authorized_via_users_server, _ => None, @@ -148,7 +145,6 @@ pub struct RedactedRoomMemberEventContent { /// /// This is redacted in room versions 8 and below. It is used for validating /// joins when the join rule is restricted. - #[cfg(feature = "unstable-spec")] #[serde(rename = "join_authorised_via_users_server")] pub join_authorized_via_users_server: Option>, } @@ -156,11 +152,7 @@ pub struct RedactedRoomMemberEventContent { impl RedactedRoomMemberEventContent { /// Create a `RedactedRoomMemberEventContent` with the given membership. pub fn new(membership: MembershipState) -> Self { - Self { - membership, - #[cfg(feature = "unstable-spec")] - join_authorized_via_users_server: None, - } + Self { membership, join_authorized_via_users_server: None } } } @@ -352,7 +344,6 @@ fn membership_change( #[cfg(feature = "unstable-pre-spec")] blurhash: None, reason: None, - #[cfg(feature = "unstable-spec")] join_authorized_via_users_server: None, } }; @@ -746,7 +737,6 @@ mod tests { ); } - #[cfg(feature = "unstable-spec")] #[test] fn serde_with_join_authorized() { let json = json!({ diff --git a/crates/ruma-state-res/Cargo.toml b/crates/ruma-state-res/Cargo.toml index 8e6ce60c..22a9ea4f 100644 --- a/crates/ruma-state-res/Cargo.toml +++ b/crates/ruma-state-res/Cargo.toml @@ -17,7 +17,7 @@ all-features = true [features] compat = [] unstable-exhaustive-types = [] -unstable-spec = ["ruma-events/unstable-spec"] +unstable-spec = [] # Private, only used in test / benchmarking code __unstable-pre-spec = ["ruma-events/unstable-pre-spec", "unstable-spec"] diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index 88c9f5ca..156ac12d 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -121,7 +121,6 @@ unstable-pre-spec = [ ] unstable-spec = [ "ruma-client-api/unstable-spec", - "ruma-events/unstable-spec", ] [dependencies]