Remove Option wrapper around directory filters
This commit is contained in:
parent
a67a396ee0
commit
90bd4874e3
@ -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")]
|
||||
|
@ -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
|
||||
|
@ -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")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user