state-res: Make all pub structs non_exhaustive
This commit is contained in:
		
							parent
							
								
									e05aad184e
								
							
						
					
					
						commit
						fae5385753
					
				| @ -16,6 +16,7 @@ all-features = true | |||||||
| 
 | 
 | ||||||
| [features] | [features] | ||||||
| unstable-pre-spec = ["ruma-events/unstable-pre-spec"] | unstable-pre-spec = ["ruma-events/unstable-pre-spec"] | ||||||
|  | unstable-exhaustive-types = [] | ||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
| itertools = "0.10.0" | itertools = "0.10.0" | ||||||
|  | |||||||
| @ -4,6 +4,9 @@ | |||||||
| // `cargo bench unknown option --save-baseline`.
 | // `cargo bench unknown option --save-baseline`.
 | ||||||
| // To pass args to criterion, use this form
 | // To pass args to criterion, use this form
 | ||||||
| // `cargo bench --bench <name of the bench> -- --save-baseline <name>`.
 | // `cargo bench --bench <name of the bench> -- --save-baseline <name>`.
 | ||||||
|  | 
 | ||||||
|  | #![allow(clippy::exhaustive_structs)] | ||||||
|  | 
 | ||||||
| use std::{ | use std::{ | ||||||
|     collections::{BTreeMap, BTreeSet}, |     collections::{BTreeMap, BTreeSet}, | ||||||
|     convert::{TryFrom, TryInto}, |     convert::{TryFrom, TryInto}, | ||||||
| @ -372,7 +375,7 @@ where | |||||||
|             auth_events, |             auth_events, | ||||||
|             prev_events, |             prev_events, | ||||||
|             depth: uint!(0), |             depth: uint!(0), | ||||||
|             hashes: EventHash { sha256: "".into() }, |             hashes: EventHash::new(String::new()), | ||||||
|             signatures: btreemap! {}, |             signatures: btreemap! {}, | ||||||
|         }), |         }), | ||||||
|     }) |     }) | ||||||
| @ -627,6 +630,8 @@ pub mod event { | |||||||
|                     _ => false, |                     _ => false, | ||||||
|                 }, |                 }, | ||||||
|                 Pdu::RoomV3Pdu(event) => event.state_key == Some("".into()), |                 Pdu::RoomV3Pdu(event) => event.state_key == Some("".into()), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -634,6 +639,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => serde_json::from_value(ev.content.clone()), |                 Pdu::RoomV1Pdu(ev) => serde_json::from_value(ev.content.clone()), | ||||||
|                 Pdu::RoomV3Pdu(ev) => serde_json::from_value(ev.content.clone()), |                 Pdu::RoomV3Pdu(ev) => serde_json::from_value(ev.content.clone()), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -641,6 +648,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.origin_server_ts, |                 Pdu::RoomV1Pdu(ev) => &ev.origin_server_ts, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.origin_server_ts, |                 Pdu::RoomV3Pdu(ev) => &ev.origin_server_ts, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -652,6 +661,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.sender, |                 Pdu::RoomV1Pdu(ev) => &ev.sender, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.sender, |                 Pdu::RoomV3Pdu(ev) => &ev.sender, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -659,6 +670,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.redacts.as_ref(), |                 Pdu::RoomV1Pdu(ev) => ev.redacts.as_ref(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.redacts.as_ref(), |                 Pdu::RoomV3Pdu(ev) => ev.redacts.as_ref(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -666,18 +679,24 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.room_id, |                 Pdu::RoomV1Pdu(ev) => &ev.room_id, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.room_id, |                 Pdu::RoomV3Pdu(ev) => &ev.room_id, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         pub fn kind(&self) -> EventType { |         pub fn kind(&self) -> EventType { | ||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.kind.clone(), |                 Pdu::RoomV1Pdu(ev) => ev.kind.clone(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.kind.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.kind.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         pub fn state_key(&self) -> Option<String> { |         pub fn state_key(&self) -> Option<String> { | ||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.state_key.clone(), |                 Pdu::RoomV1Pdu(ev) => ev.state_key.clone(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.state_key.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.state_key.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -686,6 +705,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.origin.clone(), |                 Pdu::RoomV1Pdu(ev) => ev.origin.clone(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.origin.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.origin.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -693,6 +714,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.prev_events.iter().map(|(id, _)| id).cloned().collect(), |                 Pdu::RoomV1Pdu(ev) => ev.prev_events.iter().map(|(id, _)| id).cloned().collect(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.prev_events.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.prev_events.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -700,6 +723,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.auth_events.iter().map(|(id, _)| id).cloned().collect(), |                 Pdu::RoomV1Pdu(ev) => ev.auth_events.iter().map(|(id, _)| id).cloned().collect(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.auth_events.to_vec(), |                 Pdu::RoomV3Pdu(ev) => ev.auth_events.to_vec(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -707,6 +732,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.content.clone(), |                 Pdu::RoomV1Pdu(ev) => ev.content.clone(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.content.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.content.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -714,6 +741,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.unsigned, |                 Pdu::RoomV1Pdu(ev) => &ev.unsigned, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.unsigned, |                 Pdu::RoomV3Pdu(ev) => &ev.unsigned, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -723,6 +752,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(_) => maplit::btreemap! {}, |                 Pdu::RoomV1Pdu(_) => maplit::btreemap! {}, | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.signatures.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.signatures.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -730,6 +761,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.hashes, |                 Pdu::RoomV1Pdu(ev) => &ev.hashes, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.hashes, |                 Pdu::RoomV3Pdu(ev) => &ev.hashes, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -737,6 +770,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.depth, |                 Pdu::RoomV1Pdu(ev) => &ev.depth, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.depth, |                 Pdu::RoomV3Pdu(ev) => &ev.depth, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -748,6 +783,8 @@ pub mod event { | |||||||
|                 Pdu::RoomV3Pdu(ev) => { |                 Pdu::RoomV3Pdu(ev) => { | ||||||
|                     ev.kind == ev_type && ev.state_key.as_deref() == Some(state_key) |                     ev.kind == ev_type && ev.state_key.as_deref() == Some(state_key) | ||||||
|                 } |                 } | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -760,6 +797,8 @@ pub mod event { | |||||||
|             match self.rest { |             match self.rest { | ||||||
|                 Pdu::RoomV1Pdu(_) => RoomVersionId::Version1, |                 Pdu::RoomV1Pdu(_) => RoomVersionId::Version1, | ||||||
|                 Pdu::RoomV3Pdu(_) => RoomVersionId::Version6, |                 Pdu::RoomV3Pdu(_) => RoomVersionId::Version6, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -33,6 +33,7 @@ pub type StateMap<T> = BTreeMap<(EventType, String), T>; | |||||||
| pub type EventMap<T> = BTreeMap<EventId, T>; | pub type EventMap<T> = BTreeMap<EventId, T>; | ||||||
| 
 | 
 | ||||||
| #[derive(Default)] | #[derive(Default)] | ||||||
|  | #[allow(clippy::exhaustive_structs)] | ||||||
| pub struct StateResolution; | pub struct StateResolution; | ||||||
| 
 | 
 | ||||||
| impl StateResolution { | impl StateResolution { | ||||||
|  | |||||||
| @ -26,6 +26,7 @@ pub enum StateResolutionVersion { | |||||||
|     V2, |     V2, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] | ||||||
| pub struct RoomVersion { | pub struct RoomVersion { | ||||||
|     /// The version this room is set to.
 |     /// The version this room is set to.
 | ||||||
|     pub version: RoomVersionId, |     pub version: RoomVersionId, | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| #![allow(clippy::or_fun_call, clippy::expect_fun_call, dead_code)] | #![allow(clippy::exhaustive_structs, dead_code)] | ||||||
| 
 | 
 | ||||||
| use std::{ | use std::{ | ||||||
|     collections::{BTreeMap, BTreeSet}, |     collections::{BTreeMap, BTreeSet}, | ||||||
| @ -60,14 +60,14 @@ pub fn do_check( | |||||||
| 
 | 
 | ||||||
|     for pair in INITIAL_EDGES().windows(2) { |     for pair in INITIAL_EDGES().windows(2) { | ||||||
|         if let [a, b] = &pair { |         if let [a, b] = &pair { | ||||||
|             graph.entry(a.clone()).or_insert(btreeset![]).insert(b.clone()); |             graph.entry(a.clone()).or_insert_with(BTreeSet::new).insert(b.clone()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for edge_list in edges { |     for edge_list in edges { | ||||||
|         for pair in edge_list.windows(2) { |         for pair in edge_list.windows(2) { | ||||||
|             if let [a, b] = &pair { |             if let [a, b] = &pair { | ||||||
|                 graph.entry(a.clone()).or_insert(btreeset![]).insert(b.clone()); |                 graph.entry(a.clone()).or_insert_with(BTreeSet::new).insert(b.clone()); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -173,11 +173,13 @@ pub fn do_check( | |||||||
| 
 | 
 | ||||||
|     let mut expected_state = StateMap::new(); |     let mut expected_state = StateMap::new(); | ||||||
|     for node in expected_state_ids { |     for node in expected_state_ids { | ||||||
|         let ev = event_map.get(&node).expect(&format!( |         let ev = event_map.get(&node).unwrap_or_else(|| { | ||||||
|  |             panic!( | ||||||
|                 "{} not found in {:?}", |                 "{} not found in {:?}", | ||||||
|                 node.to_string(), |                 node.to_string(), | ||||||
|             event_map.keys().map(ToString::to_string).collect::<Vec<_>>(), |                 event_map.keys().map(ToString::to_string).collect::<Vec<_>>() | ||||||
|         )); |             ) | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         let key = (ev.kind(), ev.state_key()); |         let key = (ev.kind(), ev.state_key()); | ||||||
| 
 | 
 | ||||||
| @ -334,7 +336,7 @@ pub fn to_init_pdu_event( | |||||||
|             auth_events: vec![], |             auth_events: vec![], | ||||||
|             prev_events: vec![], |             prev_events: vec![], | ||||||
|             depth: uint!(0), |             depth: uint!(0), | ||||||
|             hashes: EventHash { sha256: "".into() }, |             hashes: EventHash::new("".to_owned()), | ||||||
|             signatures: btreemap! {}, |             signatures: btreemap! {}, | ||||||
|         }), |         }), | ||||||
|     }) |     }) | ||||||
| @ -374,7 +376,7 @@ where | |||||||
|             auth_events, |             auth_events, | ||||||
|             prev_events, |             prev_events, | ||||||
|             depth: uint!(0), |             depth: uint!(0), | ||||||
|             hashes: EventHash { sha256: "".into() }, |             hashes: EventHash::new("".to_owned()), | ||||||
|             signatures: btreemap! {}, |             signatures: btreemap! {}, | ||||||
|         }), |         }), | ||||||
|     }) |     }) | ||||||
| @ -589,18 +591,24 @@ pub mod event { | |||||||
|                     _ => false, |                     _ => false, | ||||||
|                 }, |                 }, | ||||||
|                 Pdu::RoomV3Pdu(event) => event.state_key == Some("".into()), |                 Pdu::RoomV3Pdu(event) => event.state_key == Some("".into()), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         pub fn deserialize_content<C: serde::de::DeserializeOwned>(&self) -> serde_json::Result<C> { |         pub fn deserialize_content<C: serde::de::DeserializeOwned>(&self) -> serde_json::Result<C> { | ||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => serde_json::from_value(ev.content.clone()), |                 Pdu::RoomV1Pdu(ev) => serde_json::from_value(ev.content.clone()), | ||||||
|                 Pdu::RoomV3Pdu(ev) => serde_json::from_value(ev.content.clone()), |                 Pdu::RoomV3Pdu(ev) => serde_json::from_value(ev.content.clone()), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         pub fn origin_server_ts(&self) -> &MilliSecondsSinceUnixEpoch { |         pub fn origin_server_ts(&self) -> &MilliSecondsSinceUnixEpoch { | ||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.origin_server_ts, |                 Pdu::RoomV1Pdu(ev) => &ev.origin_server_ts, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.origin_server_ts, |                 Pdu::RoomV3Pdu(ev) => &ev.origin_server_ts, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         pub fn event_id(&self) -> &EventId { |         pub fn event_id(&self) -> &EventId { | ||||||
| @ -611,6 +619,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.sender, |                 Pdu::RoomV1Pdu(ev) => &ev.sender, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.sender, |                 Pdu::RoomV3Pdu(ev) => &ev.sender, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -618,6 +628,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.redacts.as_ref(), |                 Pdu::RoomV1Pdu(ev) => ev.redacts.as_ref(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.redacts.as_ref(), |                 Pdu::RoomV3Pdu(ev) => ev.redacts.as_ref(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -625,18 +637,24 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.room_id, |                 Pdu::RoomV1Pdu(ev) => &ev.room_id, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.room_id, |                 Pdu::RoomV3Pdu(ev) => &ev.room_id, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         pub fn kind(&self) -> EventType { |         pub fn kind(&self) -> EventType { | ||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.kind.clone(), |                 Pdu::RoomV1Pdu(ev) => ev.kind.clone(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.kind.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.kind.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         pub fn state_key(&self) -> String { |         pub fn state_key(&self) -> String { | ||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.state_key.clone().unwrap(), |                 Pdu::RoomV1Pdu(ev) => ev.state_key.clone().unwrap(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.state_key.clone().unwrap(), |                 Pdu::RoomV3Pdu(ev) => ev.state_key.clone().unwrap(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -645,6 +663,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.origin.clone(), |                 Pdu::RoomV1Pdu(ev) => ev.origin.clone(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.origin.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.origin.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -652,6 +672,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.prev_events.iter().map(|(id, _)| id).cloned().collect(), |                 Pdu::RoomV1Pdu(ev) => ev.prev_events.iter().map(|(id, _)| id).cloned().collect(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.prev_events.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.prev_events.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -659,6 +681,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.auth_events.iter().map(|(id, _)| id).cloned().collect(), |                 Pdu::RoomV1Pdu(ev) => ev.auth_events.iter().map(|(id, _)| id).cloned().collect(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.auth_events.to_vec(), |                 Pdu::RoomV3Pdu(ev) => ev.auth_events.to_vec(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -666,6 +690,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => ev.content.clone(), |                 Pdu::RoomV1Pdu(ev) => ev.content.clone(), | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.content.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.content.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -673,6 +699,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.unsigned, |                 Pdu::RoomV1Pdu(ev) => &ev.unsigned, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.unsigned, |                 Pdu::RoomV3Pdu(ev) => &ev.unsigned, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -682,6 +710,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(_) => maplit::btreemap! {}, |                 Pdu::RoomV1Pdu(_) => maplit::btreemap! {}, | ||||||
|                 Pdu::RoomV3Pdu(ev) => ev.signatures.clone(), |                 Pdu::RoomV3Pdu(ev) => ev.signatures.clone(), | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -689,6 +719,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.hashes, |                 Pdu::RoomV1Pdu(ev) => &ev.hashes, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.hashes, |                 Pdu::RoomV3Pdu(ev) => &ev.hashes, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -696,6 +728,8 @@ pub mod event { | |||||||
|             match &self.rest { |             match &self.rest { | ||||||
|                 Pdu::RoomV1Pdu(ev) => &ev.depth, |                 Pdu::RoomV1Pdu(ev) => &ev.depth, | ||||||
|                 Pdu::RoomV3Pdu(ev) => &ev.depth, |                 Pdu::RoomV3Pdu(ev) => &ev.depth, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -707,6 +741,8 @@ pub mod event { | |||||||
|                 Pdu::RoomV3Pdu(ev) => { |                 Pdu::RoomV3Pdu(ev) => { | ||||||
|                     ev.kind == ev_type && ev.state_key.as_deref() == Some(state_key) |                     ev.kind == ev_type && ev.state_key.as_deref() == Some(state_key) | ||||||
|                 } |                 } | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -719,6 +755,8 @@ pub mod event { | |||||||
|             match self.rest { |             match self.rest { | ||||||
|                 Pdu::RoomV1Pdu(_) => RoomVersionId::Version1, |                 Pdu::RoomV1Pdu(_) => RoomVersionId::Version1, | ||||||
|                 Pdu::RoomV3Pdu(_) => RoomVersionId::Version6, |                 Pdu::RoomV3Pdu(_) => RoomVersionId::Version6, | ||||||
|  |                 #[cfg(not(feature = "unstable-exhaustive-types"))] | ||||||
|  |                 _ => unreachable!("new PDU version"), | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -103,12 +103,14 @@ unstable-exhaustive-types = [ | |||||||
|     "ruma-federation-api/unstable-exhaustive-types", |     "ruma-federation-api/unstable-exhaustive-types", | ||||||
|     "ruma-identity-service-api/unstable-exhaustive-types", |     "ruma-identity-service-api/unstable-exhaustive-types", | ||||||
|     "ruma-push-gateway-api/unstable-exhaustive-types", |     "ruma-push-gateway-api/unstable-exhaustive-types", | ||||||
|  |     "ruma-state-res/unstable-exhaustive-types" | ||||||
| ] | ] | ||||||
| unstable-pre-spec = [ | unstable-pre-spec = [ | ||||||
|     "ruma-common/unstable-pre-spec", |     "ruma-common/unstable-pre-spec", | ||||||
|     "ruma-client-api/unstable-pre-spec", |     "ruma-client-api/unstable-pre-spec", | ||||||
|     "ruma-events/unstable-pre-spec", |     "ruma-events/unstable-pre-spec", | ||||||
|     "ruma-federation-api/unstable-pre-spec", |     "ruma-federation-api/unstable-pre-spec", | ||||||
|  |     "ruma-state-res/unstable-pre-spec" | ||||||
|     #"ruma-identity-service-api/unstable-pre-spec", |     #"ruma-identity-service-api/unstable-pre-spec", | ||||||
|     #"ruma-push-gateway-api/unstable-pre-spec", |     #"ruma-push-gateway-api/unstable-pre-spec", | ||||||
| ] | ] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user