Remove Option wrapper around directory filters

This commit is contained in:
Timo Kösters 2020-10-17 23:06:52 +02:00 committed by GitHub
parent a67a396ee0
commit 90bd4874e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -35,8 +35,8 @@ ruma_api! {
pub since: Option<&'a str>,
/// Filter to apply to the results.
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<Filter<'a>>,
#[serde(default, skip_serializing_if = "Filter::is_empty")]
pub filter: Filter<'a>,
/// Network to fetch the public room lists from.
#[serde(flatten, skip_serializing_if = "ruma_serde::is_default")]

View File

@ -98,6 +98,7 @@ impl From<PublicRoomsChunkInit> for PublicRoomsChunk {
/// A filter for public rooms lists
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[incoming_derive(Default)]
pub struct Filter<'a> {
/// A string to search for in the room metadata, e.g. name, topic, canonical alias etc.
#[serde(skip_serializing_if = "Option::is_none")]
@ -109,6 +110,11 @@ impl Filter<'_> {
pub fn new() -> Self {
Default::default()
}
/// Returns `true` if the filter is empty.
pub fn is_empty(&self) -> bool {
self.generic_search_term.is_none()
}
}
/// Information about which networks/protocols from application services on the

View File

@ -27,8 +27,8 @@ ruma_api! {
pub since: Option<&'a str>,
/// Filter to apply to the results.
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<Filter<'a>>,
#[serde(default, skip_serializing_if = "Filter::is_empty")]
pub filter: Filter<'a>,
/// Network to fetch the public room lists from.
#[serde(flatten, skip_serializing_if = "ruma_serde::is_default")]