api: Get the default room version for a Matrix version
This commit is contained in:
		
							parent
							
								
									3deae8eac7
								
							
						
					
					
						commit
						9a8d7bf475
					
				| @ -6,6 +6,7 @@ use std::{ | |||||||
| use http::Method; | use http::Method; | ||||||
| 
 | 
 | ||||||
| use super::{error::UnknownVersionError, AuthScheme}; | use super::{error::UnknownVersionError, AuthScheme}; | ||||||
|  | use crate::RoomVersionId; | ||||||
| 
 | 
 | ||||||
| /// Metadata about an API endpoint.
 | /// Metadata about an API endpoint.
 | ||||||
| #[derive(Clone, Debug)] | #[derive(Clone, Debug)] | ||||||
| @ -228,6 +229,20 @@ impl MatrixVersion { | |||||||
|             _ => Err(UnknownVersionError), |             _ => Err(UnknownVersionError), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     /// Get the default [`RoomVersionId`] for this `MatrixVersion`.
 | ||||||
|  |     pub fn default_room_version(&self) -> RoomVersionId { | ||||||
|  |         match self { | ||||||
|  |             // <https://matrix.org/docs/spec/index.html#complete-list-of-room-versions>
 | ||||||
|  |             MatrixVersion::V1_0 | ||||||
|  |             // <https://spec.matrix.org/v1.1/rooms/#complete-list-of-room-versions>
 | ||||||
|  |             | MatrixVersion::V1_1 | ||||||
|  |             // <https://spec.matrix.org/v1.2/rooms/#complete-list-of-room-versions>
 | ||||||
|  |             | MatrixVersion::V1_2 => RoomVersionId::V6, | ||||||
|  |             // <https://spec.matrix.org/v1.3/rooms/#complete-list-of-room-versions>
 | ||||||
|  |             MatrixVersion::V1_3 => RoomVersionId::V9, | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Display for MatrixVersion { | impl Display for MatrixVersion { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user