Make limit in user_directory/search a smart field

This commit is contained in:
timokoesters 2020-07-30 11:10:02 +02:00
parent 50a33c8089
commit 8650ae00da
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
2 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,10 @@
# [unreleased]
Breaking changes:
* Update type of `limit` in `r0::user_directory::search_users` from
`Option<UInt>` to `UInt`
# 0.10.0
Bug fixes:

View File

@ -1,6 +1,6 @@
//! [POST /_matrix/client/r0/user_directory/search](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-user-directory-search)
use js_int::UInt;
use js_int::{uint, UInt};
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
use serde::{Deserialize, Serialize};
@ -22,8 +22,8 @@ ruma_api! {
/// The maximum number of results to return.
///
/// Defaults to 10.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<UInt>,
#[serde(default = "default_limit", skip_serializing_if = "is_default_limit")]
pub limit: UInt,
}
response: {
@ -37,6 +37,14 @@ ruma_api! {
error: crate::Error
}
fn default_limit() -> UInt {
uint!(10)
}
fn is_default_limit(limit: &UInt) -> bool {
limit == &default_limit()
}
/// User data as result of a search.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct User {