events: Remove unstable-spec feature

Everything that was gated behind it was stabilized with Matrix v1.2.
This commit is contained in:
Jonas Platte 2022-02-02 23:11:36 +01:00
parent e9994b89c8
commit 71a7dbdc43
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
8 changed files with 7 additions and 56 deletions

View File

@ -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 }

View File

@ -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",
}

View File

@ -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;

View File

@ -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<RoomType>,
}
@ -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"
);

View File

@ -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<AllowRule>) -> 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<AllowRule>,
}
#[cfg(feature = "unstable-spec")]
impl Restricted {
/// Constructs a new rule set for restricted rooms with the given rules.
pub fn new(allow: Vec<AllowRule>) -> 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<RoomId>) -> 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<RoomId>,
}
#[cfg(feature = "unstable-spec")]
impl RoomMembership {
/// Constructs a new room membership rule for the given room id.
pub fn new(room_id: Box<RoomId>) -> 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<String, JsonValue>,
}
#[cfg(feature = "unstable-spec")]
impl<'de> Deserialize<'de> for AllowRule {
fn deserialize<D>(deserializer: D) -> Result<AllowRule, D::Error>
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#"{

View File

@ -98,7 +98,6 @@ pub struct RoomMemberEventContent {
pub reason: Option<String>,
/// 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<Box<UserId>>,
@ -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<Box<UserId>>,
}
@ -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!({

View File

@ -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"]

View File

@ -121,7 +121,6 @@ unstable-pre-spec = [
]
unstable-spec = [
"ruma-client-api/unstable-spec",
"ruma-events/unstable-spec",
]
[dependencies]