client-api: Update directory endpoints to the new API standards
This commit is contained in:
		
							parent
							
								
									76058b8170
								
							
						
					
					
						commit
						e2406cc8f0
					
				| @ -14,6 +14,8 @@ ruma_api! { | |||||||
|         requires_authentication: false, |         requires_authentication: false, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     #[derive(Default)] | ||||||
|  |     #[non_exhaustive] | ||||||
|     request: { |     request: { | ||||||
|         /// Limit for the number of results to return.
 |         /// Limit for the number of results to return.
 | ||||||
|         #[serde(skip_serializing_if = "Option::is_none")] |         #[serde(skip_serializing_if = "Option::is_none")] | ||||||
| @ -33,23 +35,41 @@ ruma_api! { | |||||||
|         pub server: Option<&'a str>, |         pub server: Option<&'a str>, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     #[non_exhaustive] | ||||||
|     response: { |     response: { | ||||||
|         /// A paginated chunk of public rooms.
 |         /// A paginated chunk of public rooms.
 | ||||||
|         pub chunk: Vec<PublicRoomsChunk>, |         pub chunk: Vec<PublicRoomsChunk>, | ||||||
| 
 | 
 | ||||||
|         /// A pagination token for the response.
 |         /// A pagination token for the response.
 | ||||||
|  |         #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|         pub next_batch: Option<String>, |         pub next_batch: Option<String>, | ||||||
| 
 | 
 | ||||||
|         /// A pagination token that allows fetching previous results.
 |         /// A pagination token that allows fetching previous results.
 | ||||||
|  |         #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|         pub prev_batch: Option<String>, |         pub prev_batch: Option<String>, | ||||||
| 
 | 
 | ||||||
|         /// An estimate on the total number of public rooms, if the server has an estimate.
 |         /// An estimate on the total number of public rooms, if the server has an estimate.
 | ||||||
|  |         #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|         pub total_room_count_estimate: Option<UInt>, |         pub total_room_count_estimate: Option<UInt>, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     error: crate::Error |     error: crate::Error | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl<'a> Request<'a> { | ||||||
|  |     /// Creates an empty `Request`.
 | ||||||
|  |     pub fn new() -> Self { | ||||||
|  |         Default::default() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | impl Response { | ||||||
|  |     /// Creates a new `Response` with the given room list chunk.
 | ||||||
|  |     pub fn new(chunk: Vec<PublicRoomsChunk>) -> Self { | ||||||
|  |         Self { chunk, next_batch: None, prev_batch: None, total_room_count_estimate: None } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #[cfg(test)] | #[cfg(test)] | ||||||
| mod tests { | mod tests { | ||||||
|     use std::convert::TryInto; |     use std::convert::TryInto; | ||||||
|  | |||||||
| @ -15,12 +15,14 @@ ruma_api! { | |||||||
|         requires_authentication: false, |         requires_authentication: false, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     #[non_exhaustive] | ||||||
|     request: { |     request: { | ||||||
|         /// The ID of the room of which to request the visibility.
 |         /// The ID of the room of which to request the visibility.
 | ||||||
|         #[ruma_api(path)] |         #[ruma_api(path)] | ||||||
|         pub room_id: RoomId, |         pub room_id: &'a RoomId, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     #[non_exhaustive] | ||||||
|     response: { |     response: { | ||||||
|         /// Visibility of the room.
 |         /// Visibility of the room.
 | ||||||
|         pub visibility: Visibility, |         pub visibility: Visibility, | ||||||
| @ -28,3 +30,17 @@ ruma_api! { | |||||||
| 
 | 
 | ||||||
|     error: crate::Error |     error: crate::Error | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | impl<'a> Request<'a> { | ||||||
|  |     /// Creates a new `Request` with the given room ID.
 | ||||||
|  |     pub fn new(room_id: &'a RoomId) -> Self { | ||||||
|  |         Self { room_id } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | impl Response { | ||||||
|  |     /// Creates a new `Response` with the given visibility.
 | ||||||
|  |     pub fn new(visibility: Visibility) -> Self { | ||||||
|  |         Self { visibility } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | |||||||
| @ -15,16 +15,33 @@ ruma_api! { | |||||||
|         requires_authentication: true, |         requires_authentication: true, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     #[non_exhaustive] | ||||||
|     request: { |     request: { | ||||||
|         /// The ID of the room of which to set the visibility.
 |         /// The ID of the room of which to set the visibility.
 | ||||||
|         #[ruma_api(path)] |         #[ruma_api(path)] | ||||||
|         pub room_id: RoomId, |         pub room_id: &'a RoomId, | ||||||
| 
 | 
 | ||||||
|         /// New visibility setting for the room.
 |         /// New visibility setting for the room.
 | ||||||
|         pub visibility: Visibility, |         pub visibility: Visibility, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     #[derive(Default)] | ||||||
|  |     #[non_exhaustive] | ||||||
|     response: {} |     response: {} | ||||||
| 
 | 
 | ||||||
|     error: crate::Error |     error: crate::Error | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | impl<'a> Request<'a> { | ||||||
|  |     /// Creates a new `Request` with the given room ID and visibility.
 | ||||||
|  |     pub fn new(room_id: &'a RoomId, visibility: Visibility) -> Self { | ||||||
|  |         Self { room_id, visibility } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | impl Response { | ||||||
|  |     /// Creates an empty `Response`.
 | ||||||
|  |     pub fn new() -> Self { | ||||||
|  |         Self | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user