From 6b76d7813e8e913ef90b9ddfedcd77acc3d4aadd Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 26 Nov 2021 00:50:01 +0100 Subject: [PATCH] identifiers: Shorten RoomVersionId variant names --- crates/ruma-client-api/src/r0/capabilities.rs | 8 +- crates/ruma-events/src/room/aliases.rs | 10 +-- crates/ruma-events/src/room/create.rs | 12 +-- crates/ruma-events/tests/redacted.rs | 9 +-- .../knock/create_knock_event_template/v1.rs | 4 +- .../create_join_event_template/v1.rs | 8 +- crates/ruma-identifiers/CHANGELOG.md | 1 + .../ruma-identifiers/src/room_version_id.rs | 74 +++++++++---------- crates/ruma-signatures/src/functions.rs | 32 ++++---- crates/ruma-signatures/src/lib.rs | 6 +- .../ruma-state-res/benches/state_res_bench.rs | 4 +- crates/ruma-state-res/src/lib.rs | 4 +- crates/ruma-state-res/src/room_version.rs | 41 +++++----- crates/ruma-state-res/src/test_utils.rs | 7 +- 14 files changed, 104 insertions(+), 116 deletions(-) diff --git a/crates/ruma-client-api/src/r0/capabilities.rs b/crates/ruma-client-api/src/r0/capabilities.rs index 61400877..43e7128d 100644 --- a/crates/ruma-client-api/src/r0/capabilities.rs +++ b/crates/ruma-client-api/src/r0/capabilities.rs @@ -142,11 +142,11 @@ impl RoomVersionsCapability { /// Returns whether all fields have their default value. pub fn is_default(&self) -> bool { - self.default == RoomVersionId::Version1 + self.default == RoomVersionId::V1 && self.available.len() == 1 && self .available - .get(&RoomVersionId::Version1) + .get(&RoomVersionId::V1) .map(|stability| *stability == RoomVersionStability::Stable) .unwrap_or(false) } @@ -155,8 +155,8 @@ impl RoomVersionsCapability { impl Default for RoomVersionsCapability { fn default() -> Self { Self { - default: RoomVersionId::Version1, - available: btreemap! { RoomVersionId::Version1 => RoomVersionStability::Stable }, + default: RoomVersionId::V1, + available: btreemap! { RoomVersionId::V1 => RoomVersionStability::Stable }, } } } diff --git a/crates/ruma-events/src/room/aliases.rs b/crates/ruma-events/src/room/aliases.rs index ee8307ca..da09267c 100644 --- a/crates/ruma-events/src/room/aliases.rs +++ b/crates/ruma-events/src/room/aliases.rs @@ -35,11 +35,11 @@ impl RedactContent for RoomAliasesEventContent { // We compare the long way to avoid pre version 6 behavior if/when // a new room version is introduced. let aliases = match version { - RoomVersionId::Version1 - | RoomVersionId::Version2 - | RoomVersionId::Version3 - | RoomVersionId::Version4 - | RoomVersionId::Version5 => Some(self.aliases), + RoomVersionId::V1 + | RoomVersionId::V2 + | RoomVersionId::V3 + | RoomVersionId::V4 + | RoomVersionId::V5 => Some(self.aliases), _ => None, }; diff --git a/crates/ruma-events/src/room/create.rs b/crates/ruma-events/src/room/create.rs index 6b80b331..1336c411 100644 --- a/crates/ruma-events/src/room/create.rs +++ b/crates/ruma-events/src/room/create.rs @@ -30,7 +30,7 @@ pub struct RoomCreateEventContent { /// The version of the room. /// - /// Defaults to `RoomVersionId::Version1`. + /// Defaults to `RoomVersionId::V1`. #[serde(default = "default_room_version_id")] pub room_version: RoomVersionId, @@ -102,7 +102,7 @@ impl PreviousRoom { /// Used to default the `room_version` field to room version 1. fn default_room_version_id() -> RoomVersionId { - RoomVersionId::Version1 + RoomVersionId::V1 } #[cfg(test)] @@ -121,7 +121,7 @@ mod tests { let content = RoomCreateEventContent { creator: user_id!("@carl:example.com").to_owned(), federate: false, - room_version: RoomVersionId::Version4, + room_version: RoomVersionId::V4, predecessor: None, #[cfg(feature = "unstable-pre-spec")] room_type: None, @@ -142,7 +142,7 @@ mod tests { let content = RoomCreateEventContent { creator: user_id!("@carl:example.com").to_owned(), federate: false, - room_version: RoomVersionId::Version4, + room_version: RoomVersionId::V4, predecessor: None, room_type: Some(RoomType::Space), }; @@ -170,7 +170,7 @@ mod tests { RoomCreateEventContent { creator, federate: true, - room_version: RoomVersionId::Version4, + room_version: RoomVersionId::V4, predecessor: None, #[cfg(feature = "unstable-pre-spec")] room_type: None, @@ -193,7 +193,7 @@ mod tests { RoomCreateEventContent { creator, federate: true, - room_version: RoomVersionId::Version4, + room_version: RoomVersionId::V4, predecessor: None, room_type } if creator == "@carl:example.com" && room_type == Some(RoomType::Space) diff --git a/crates/ruma-events/tests/redacted.rs b/crates/ruma-events/tests/redacted.rs index 122cbd2b..786a865a 100644 --- a/crates/ruma-events/tests/redacted.rs +++ b/crates/ruma-events/tests/redacted.rs @@ -296,7 +296,7 @@ fn redact_method_properly_redacts() { let event: AnyMessageEvent = from_json_value(ev).unwrap(); assert_matches!( - event.redact(redaction, &RoomVersionId::Version6), + event.redact(redaction, &RoomVersionId::V6), AnyRedactedMessageEvent::RoomMessage(RedactedMessageEvent { content: RedactedRoomMessageEventContent { .. }, event_id, @@ -323,10 +323,7 @@ fn redact_message_content() { let raw_json = to_raw_value(&json).unwrap(); let content = RoomMessageEventContent::from_parts("m.room.message", &raw_json).unwrap(); - assert_matches!( - content.redact(&RoomVersionId::Version6), - RedactedRoomMessageEventContent { .. } - ); + assert_matches!(content.redact(&RoomVersionId::V6), RedactedRoomMessageEventContent { .. }); } #[test] @@ -341,7 +338,7 @@ fn redact_state_content() { let content = RoomCreateEventContent::from_parts("m.room.create", &raw_json).unwrap(); assert_matches!( - content.redact(&RoomVersionId::Version6), + content.redact(&RoomVersionId::V6), RedactedRoomCreateEventContent { creator, .. diff --git a/crates/ruma-federation-api/src/knock/create_knock_event_template/v1.rs b/crates/ruma-federation-api/src/knock/create_knock_event_template/v1.rs index c27daf97..ba54f538 100644 --- a/crates/ruma-federation-api/src/knock/create_knock_event_template/v1.rs +++ b/crates/ruma-federation-api/src/knock/create_knock_event_template/v1.rs @@ -25,7 +25,7 @@ ruma_api! { /// The room versions the sending has support for. /// - /// Defaults to `&[RoomVersionId::Version1]`. + /// Defaults to `&[RoomVersionId::V1]`. #[ruma_api(query)] pub ver: &'a [RoomVersionId], } @@ -44,7 +44,7 @@ ruma_api! { impl<'a> Request<'a> { /// Creates a `Request` with the given room ID and user ID. pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self { - Self { room_id, user_id, ver: &[RoomVersionId::Version1] } + Self { room_id, user_id, ver: &[RoomVersionId::V1] } } } diff --git a/crates/ruma-federation-api/src/membership/create_join_event_template/v1.rs b/crates/ruma-federation-api/src/membership/create_join_event_template/v1.rs index 3f672184..80ebf112 100644 --- a/crates/ruma-federation-api/src/membership/create_join_event_template/v1.rs +++ b/crates/ruma-federation-api/src/membership/create_join_event_template/v1.rs @@ -26,7 +26,7 @@ ruma_api! { /// The room versions the sending server has support for. /// - /// Defaults to `&[RoomVersionId::Version1]`. + /// Defaults to `&[RoomVersionId::V1]`. #[ruma_api(query)] #[serde(default = "default_ver", skip_serializing_if = "is_default_ver")] pub ver: &'a [RoomVersionId], @@ -43,17 +43,17 @@ ruma_api! { } fn default_ver() -> Vec { - vec![RoomVersionId::Version1] + vec![RoomVersionId::V1] } fn is_default_ver(ver: &&[RoomVersionId]) -> bool { - **ver == [RoomVersionId::Version1] + **ver == [RoomVersionId::V1] } impl<'a> Request<'a> { /// Creates a new `Request` with the given room id and user id. pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self { - Self { room_id, user_id, ver: &[RoomVersionId::Version1] } + Self { room_id, user_id, ver: &[RoomVersionId::V1] } } } diff --git a/crates/ruma-identifiers/CHANGELOG.md b/crates/ruma-identifiers/CHANGELOG.md index 254096dd..0b3d6052 100644 --- a/crates/ruma-identifiers/CHANGELOG.md +++ b/crates/ruma-identifiers/CHANGELOG.md @@ -9,6 +9,7 @@ Breaking changes: (these *might* be converted into the same kind of type at some point in the future) * The corresponding macros (and also `server_name!`) now return `'static` references instead of owned values now – use `.to_owned()` to get an owned copy +* Rename `RoomVersionId::Version{X}` variants to `RoomVersionId::V{X}` # 0.20.0 diff --git a/crates/ruma-identifiers/src/room_version_id.rs b/crates/ruma-identifiers/src/room_version_id.rs index 31f95753..372615ed 100644 --- a/crates/ruma-identifiers/src/room_version_id.rs +++ b/crates/ruma-identifiers/src/room_version_id.rs @@ -25,34 +25,34 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub enum RoomVersionId { /// A version 1 room. - Version1, + V1, /// A version 2 room. - Version2, + V2, /// A version 3 room. - Version3, + V3, /// A version 4 room. - Version4, + V4, /// A version 5 room. - Version5, + V5, /// A version 6 room. - Version6, + V6, /// A version 7 room. #[cfg(feature = "unstable-pre-spec")] - Version7, + V7, /// A version 8 room. #[cfg(feature = "unstable-pre-spec")] - Version8, + V8, /// A version 9 room. #[cfg(feature = "unstable-pre-spec")] - Version9, + V9, #[doc(hidden)] _Custom(CustomRoomVersion), @@ -64,18 +64,18 @@ impl RoomVersionId { // FIXME: Add support for non-`str`-deref'ing types for fallback to AsRefStr derive and // implement this function in terms of `AsRef` match &self { - Self::Version1 => "1", - Self::Version2 => "2", - Self::Version3 => "3", - Self::Version4 => "4", - Self::Version5 => "5", - Self::Version6 => "6", + Self::V1 => "1", + Self::V2 => "2", + Self::V3 => "3", + Self::V4 => "4", + Self::V5 => "5", + Self::V6 => "6", #[cfg(feature = "unstable-pre-spec")] - Self::Version7 => "7", + Self::V7 => "7", #[cfg(feature = "unstable-pre-spec")] - Self::Version8 => "8", + Self::V8 => "8", #[cfg(feature = "unstable-pre-spec")] - Self::Version9 => "9", + Self::V9 => "9", Self::_Custom(version) => version.as_str(), } } @@ -89,18 +89,18 @@ impl RoomVersionId { impl From for String { fn from(id: RoomVersionId) -> Self { match id { - RoomVersionId::Version1 => "1".to_owned(), - RoomVersionId::Version2 => "2".to_owned(), - RoomVersionId::Version3 => "3".to_owned(), - RoomVersionId::Version4 => "4".to_owned(), - RoomVersionId::Version5 => "5".to_owned(), - RoomVersionId::Version6 => "6".to_owned(), + RoomVersionId::V1 => "1".to_owned(), + RoomVersionId::V2 => "2".to_owned(), + RoomVersionId::V3 => "3".to_owned(), + RoomVersionId::V4 => "4".to_owned(), + RoomVersionId::V5 => "5".to_owned(), + RoomVersionId::V6 => "6".to_owned(), #[cfg(feature = "unstable-pre-spec")] - RoomVersionId::Version7 => "7".to_owned(), + RoomVersionId::V7 => "7".to_owned(), #[cfg(feature = "unstable-pre-spec")] - RoomVersionId::Version8 => "8".to_owned(), + RoomVersionId::V8 => "8".to_owned(), #[cfg(feature = "unstable-pre-spec")] - RoomVersionId::Version9 => "9".to_owned(), + RoomVersionId::V9 => "9".to_owned(), RoomVersionId::_Custom(version) => version.into(), } } @@ -160,18 +160,18 @@ where S: AsRef + Into>, { let version = match room_version_id.as_ref() { - "1" => RoomVersionId::Version1, - "2" => RoomVersionId::Version2, - "3" => RoomVersionId::Version3, - "4" => RoomVersionId::Version4, - "5" => RoomVersionId::Version5, - "6" => RoomVersionId::Version6, + "1" => RoomVersionId::V1, + "2" => RoomVersionId::V2, + "3" => RoomVersionId::V3, + "4" => RoomVersionId::V4, + "5" => RoomVersionId::V5, + "6" => RoomVersionId::V6, #[cfg(feature = "unstable-pre-spec")] - "7" => RoomVersionId::Version7, + "7" => RoomVersionId::V7, #[cfg(feature = "unstable-pre-spec")] - "8" => RoomVersionId::Version8, + "8" => RoomVersionId::V8, #[cfg(feature = "unstable-pre-spec")] - "9" => RoomVersionId::Version9, + "9" => RoomVersionId::V9, custom => { ruma_identifiers_validation::room_version_id::validate(custom)?; RoomVersionId::_Custom(CustomRoomVersion(room_version_id.into())) @@ -349,7 +349,7 @@ mod tests { let deserialized = serde_json::from_str::(r#""1""#) .expect("Failed to convert RoomVersionId to JSON."); - assert_eq!(deserialized, RoomVersionId::Version1); + assert_eq!(deserialized, RoomVersionId::V1); assert_eq!( deserialized, diff --git a/crates/ruma-signatures/src/functions.rs b/crates/ruma-signatures/src/functions.rs index ec9fe426..f9aea68a 100644 --- a/crates/ruma-signatures/src/functions.rs +++ b/crates/ruma-signatures/src/functions.rs @@ -58,11 +58,11 @@ fn allowed_content_keys_for(event_type: &str, version: &RoomVersionId) -> &'stat "users_default", ], "m.room.aliases" => match version { - RoomVersionId::Version1 - | RoomVersionId::Version2 - | RoomVersionId::Version3 - | RoomVersionId::Version4 - | RoomVersionId::Version5 => &["aliases"], + RoomVersionId::V1 + | RoomVersionId::V2 + | RoomVersionId::V3 + | RoomVersionId::V4 + | RoomVersionId::V5 => &["aliases"], // All other room versions, including custom ones, are treated by version 6 rules. // TODO: Should we return an error for unknown versions instead? _ => &[], @@ -387,9 +387,7 @@ pub fn reference_hash( Ok(encode_config( &hash, match version { - RoomVersionId::Version1 | RoomVersionId::Version2 | RoomVersionId::Version3 => { - STANDARD_NO_PAD - } + RoomVersionId::V1 | RoomVersionId::V2 | RoomVersionId::V3 => STANDARD_NO_PAD, // Room versions higher than version 3 are url safe base64 encoded _ => URL_SAFE_NO_PAD, }, @@ -458,7 +456,7 @@ pub fn reference_hash( /// ).unwrap(); /// /// // Hash and sign the JSON with the key pair. -/// assert!(hash_and_sign_event("domain", &key_pair, &mut object, &RoomVersionId::Version1).is_ok()); +/// assert!(hash_and_sign_event("domain", &key_pair, &mut object, &RoomVersionId::V1).is_ok()); /// ``` /// /// This will modify the JSON from the structure shown to a structure like this: @@ -583,7 +581,7 @@ where /// public_key_map.insert("domain".into(), public_key_set); /// /// // Verify at least one signature for each entity in `public_key_map`. -/// let verification_result = verify_event(&public_key_map, &object, &RoomVersionId::Version6); +/// let verification_result = verify_event(&public_key_map, &object, &RoomVersionId::V6); /// assert!(verification_result.is_ok()); /// assert!(matches!(verification_result.unwrap(), Verified::All)); /// ``` @@ -790,7 +788,7 @@ fn servers_to_check_signatures( } match version { - RoomVersionId::Version1 | RoomVersionId::Version2 => match object.get("event_id") { + RoomVersionId::V1 | RoomVersionId::V2 => match object.get("event_id") { Some(CanonicalJsonValue::String(raw_event_id)) => { let event_id: Box = raw_event_id.parse().map_err(|e| Error::from(ParseError::EventId(e)))?; @@ -933,8 +931,7 @@ mod tests { ).unwrap(); let public_key_map = BTreeMap::new(); - let verification_result = - verify_event(&public_key_map, &signed_event, &RoomVersionId::Version6); + let verification_result = verify_event(&public_key_map, &signed_event, &RoomVersionId::V6); assert!(verification_result.is_ok()); let verification = verification_result.unwrap(); @@ -987,8 +984,7 @@ mod tests { add_key_to_map(&mut public_key_map, "domain-sender", &key_pair_sender); add_key_to_map(&mut public_key_map, "domain-event", &key_pair_event); - let verification_result = - verify_event(&public_key_map, &signed_event, &RoomVersionId::Version1); + let verification_result = verify_event(&public_key_map, &signed_event, &RoomVersionId::V1); assert!(verification_result.is_ok()); let verification = verification_result.unwrap(); @@ -1023,8 +1019,7 @@ mod tests { // Verify with an empty public key map should fail due to missing public keys let public_key_map = BTreeMap::new(); - let verification_result = - verify_event(&public_key_map, &signed_event, &RoomVersionId::Version6); + let verification_result = verify_event(&public_key_map, &signed_event, &RoomVersionId::V6); assert!(verification_result.is_err()); let error_msg = verification_result.err().unwrap(); @@ -1073,8 +1068,7 @@ mod tests { sender_key_map.insert(version.to_string(), encoded_public_key); public_key_map.insert("domain-sender".to_owned(), sender_key_map); - let verification_result = - verify_event(&public_key_map, &signed_event, &RoomVersionId::Version6); + let verification_result = verify_event(&public_key_map, &signed_event, &RoomVersionId::V6); assert!(verification_result.is_err()); let error_msg = verification_result.err().unwrap(); diff --git a/crates/ruma-signatures/src/lib.rs b/crates/ruma-signatures/src/lib.rs index 2c49fc01..174be8e5 100644 --- a/crates/ruma-signatures/src/lib.rs +++ b/crates/ruma-signatures/src/lib.rs @@ -341,7 +341,7 @@ mod tests { }"#; let mut object = from_json_str(json).unwrap(); - hash_and_sign_event("domain", &key_pair, &mut object, &RoomVersionId::Version5).unwrap(); + hash_and_sign_event("domain", &key_pair, &mut object, &RoomVersionId::V5).unwrap(); assert_eq!( to_json_string(&object).unwrap(), @@ -374,7 +374,7 @@ mod tests { }"#; let mut object = from_json_str(json).unwrap(); - hash_and_sign_event("domain", &key_pair, &mut object, &RoomVersionId::Version5).unwrap(); + hash_and_sign_event("domain", &key_pair, &mut object, &RoomVersionId::V5).unwrap(); assert_eq!( to_json_string(&object).unwrap(), @@ -415,6 +415,6 @@ mod tests { }"# ).unwrap(); - assert!(verify_event(&public_key_map, &value, &RoomVersionId::Version5).is_ok()); + assert!(verify_event(&public_key_map, &value, &RoomVersionId::V5).is_ok()); } } diff --git a/crates/ruma-state-res/benches/state_res_bench.rs b/crates/ruma-state-res/benches/state_res_bench.rs index cac9f28a..f782227f 100644 --- a/crates/ruma-state-res/benches/state_res_bench.rs +++ b/crates/ruma-state-res/benches/state_res_bench.rs @@ -66,7 +66,7 @@ fn resolution_shallow_auth_chain(c: &mut Criterion) { let ev_map = store.0.clone(); let state_sets = [&state_at_bob, &state_at_charlie]; let _ = match state_res::resolve( - &RoomVersionId::Version6, + &RoomVersionId::V6, state_sets, state_sets .iter() @@ -130,7 +130,7 @@ fn resolve_deeper_event_set(c: &mut Criterion) { b.iter(|| { let state_sets = [&state_set_a, &state_set_b]; let _ = match state_res::resolve( - &RoomVersionId::Version6, + &RoomVersionId::V6, state_sets, state_sets .iter() diff --git a/crates/ruma-state-res/src/lib.rs b/crates/ruma-state-res/src/lib.rs index 0acfe025..0e695baf 100644 --- a/crates/ruma-state-res/src/lib.rs +++ b/crates/ruma-state-res/src/lib.rs @@ -1039,7 +1039,7 @@ mod tests { let ev_map: EventMap> = store.0.clone(); let state_sets = [state_at_bob, state_at_charlie]; let resolved = match crate::resolve( - &RoomVersionId::Version2, + &RoomVersionId::V2, &state_sets, state_sets .iter() @@ -1143,7 +1143,7 @@ mod tests { let ev_map: EventMap> = store.0.clone(); let state_sets = [state_set_a, state_set_b]; let resolved = match crate::resolve( - &RoomVersionId::Version6, + &RoomVersionId::V6, &state_sets, state_sets .iter() diff --git a/crates/ruma-state-res/src/room_version.rs b/crates/ruma-state-res/src/room_version.rs index 7478fb9e..68d54d4f 100644 --- a/crates/ruma-state-res/src/room_version.rs +++ b/crates/ruma-state-res/src/room_version.rs @@ -72,7 +72,7 @@ pub struct RoomVersion { impl RoomVersion { pub const VERSION1: Self = Self { - version: RoomVersionId::Version1, + version: RoomVersionId::V1, disposition: RoomDisposition::Stable, event_format: EventFormatVersion::V1, state_res: StateResolutionVersion::V1, @@ -86,29 +86,26 @@ impl RoomVersion { }; pub const VERSION2: Self = Self { - version: RoomVersionId::Version2, + version: RoomVersionId::V2, state_res: StateResolutionVersion::V2, ..Self::VERSION1 }; pub const VERSION3: Self = Self { - version: RoomVersionId::Version3, + version: RoomVersionId::V3, event_format: EventFormatVersion::V2, extra_redaction_checks: true, ..Self::VERSION2 }; - pub const VERSION4: Self = Self { - version: RoomVersionId::Version4, - event_format: EventFormatVersion::V3, - ..Self::VERSION3 - }; + pub const VERSION4: Self = + Self { version: RoomVersionId::V4, event_format: EventFormatVersion::V3, ..Self::VERSION3 }; pub const VERSION5: Self = - Self { version: RoomVersionId::Version5, enforce_key_validity: true, ..Self::VERSION4 }; + Self { version: RoomVersionId::V5, enforce_key_validity: true, ..Self::VERSION4 }; pub const VERSION6: Self = Self { - version: RoomVersionId::Version5, + version: RoomVersionId::V5, special_case_aliases_auth: false, strict_canonicaljson: true, limit_notifications_power_levels: true, @@ -117,7 +114,7 @@ impl RoomVersion { #[cfg(feature = "unstable-pre-spec")] pub const VERSION7: Self = Self { - version: RoomVersionId::Version7, + version: RoomVersionId::V7, // FIXME: once room version 7 is stabilized move this to version 8 disposition: RoomDisposition::Unstable, allow_knocking: true, @@ -126,25 +123,25 @@ impl RoomVersion { #[cfg(feature = "unstable-pre-spec")] pub const VERSION8: Self = - Self { version: RoomVersionId::Version8, restricted_join_rules: true, ..Self::VERSION7 }; + Self { version: RoomVersionId::V8, restricted_join_rules: true, ..Self::VERSION7 }; #[cfg(feature = "unstable-pre-spec")] - pub const VERSION9: Self = Self { version: RoomVersionId::Version9, ..Self::VERSION8 }; + pub const VERSION9: Self = Self { version: RoomVersionId::V9, ..Self::VERSION8 }; pub fn new(version: &RoomVersionId) -> Result { Ok(match version { - RoomVersionId::Version1 => Self::VERSION1, - RoomVersionId::Version2 => Self::VERSION2, - RoomVersionId::Version3 => Self::VERSION3, - RoomVersionId::Version4 => Self::VERSION4, - RoomVersionId::Version5 => Self::VERSION5, - RoomVersionId::Version6 => Self::VERSION6, + RoomVersionId::V1 => Self::VERSION1, + RoomVersionId::V2 => Self::VERSION2, + RoomVersionId::V3 => Self::VERSION3, + RoomVersionId::V4 => Self::VERSION4, + RoomVersionId::V5 => Self::VERSION5, + RoomVersionId::V6 => Self::VERSION6, #[cfg(feature = "unstable-pre-spec")] - RoomVersionId::Version7 => Self::VERSION7, + RoomVersionId::V7 => Self::VERSION7, #[cfg(feature = "unstable-pre-spec")] - RoomVersionId::Version8 => Self::VERSION8, + RoomVersionId::V8 => Self::VERSION8, #[cfg(feature = "unstable-pre-spec")] - RoomVersionId::Version9 => Self::VERSION9, + RoomVersionId::V9 => Self::VERSION9, ver => return Err(Error::Unsupported(format!("found version `{}`", ver.as_str()))), }) } diff --git a/crates/ruma-state-res/src/test_utils.rs b/crates/ruma-state-res/src/test_utils.rs index c7967eb3..d5a7e249 100644 --- a/crates/ruma-state-res/src/test_utils.rs +++ b/crates/ruma-state-res/src/test_utils.rs @@ -116,10 +116,9 @@ pub fn do_check( }) .collect(); - let resolved = - crate::resolve(&RoomVersionId::Version6, state_sets, auth_chain_sets, |id| { - event_map.get(id).map(Arc::clone) - }); + let resolved = crate::resolve(&RoomVersionId::V6, state_sets, auth_chain_sets, |id| { + event_map.get(id).map(Arc::clone) + }); match resolved { Ok(state) => state, Err(e) => panic!("resolution for {} failed: {}", node, e),