client-api: Make sync_events request and response types non-exhaustive
This commit is contained in:
parent
83140b585c
commit
277800b980
@ -24,6 +24,7 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// A filter represented either as its full JSON definition or the ID of a saved filter.
|
/// A filter represented either as its full JSON definition or the ID of a saved filter.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -58,6 +59,7 @@ ruma_api! {
|
|||||||
pub timeout: Option<Duration>,
|
pub timeout: Option<Duration>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The batch token to supply in the `since` param of the next `/sync` request.
|
/// The batch token to supply in the `since` param of the next `/sync` request.
|
||||||
pub next_batch: String,
|
pub next_batch: String,
|
||||||
@ -93,6 +95,34 @@ ruma_api! {
|
|||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
filter: None,
|
||||||
|
since: None,
|
||||||
|
full_state: false,
|
||||||
|
set_presence: Default::default(),
|
||||||
|
timeout: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a `Response` with the given batch token.
|
||||||
|
pub fn new(next_batch: String) -> Self {
|
||||||
|
Self {
|
||||||
|
next_batch,
|
||||||
|
rooms: Default::default(),
|
||||||
|
presence: Default::default(),
|
||||||
|
account_data: Default::default(),
|
||||||
|
to_device: Default::default(),
|
||||||
|
device_lists: Default::default(),
|
||||||
|
device_one_time_keys_count: BTreeMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A filter represented either as its full JSON definition or the ID of a saved filter.
|
/// A filter represented either as its full JSON definition or the ID of a saved filter.
|
||||||
#[derive(Clone, Copy, Debug, Outgoing, Serialize)]
|
#[derive(Clone, Copy, Debug, Outgoing, Serialize)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
@ -334,13 +334,12 @@ where
|
|||||||
|
|
||||||
async move {
|
async move {
|
||||||
let response = client
|
let response = client
|
||||||
.request(SyncRequest {
|
.request(assign!(SyncRequest::new(), {
|
||||||
filter,
|
filter,
|
||||||
since: since.as_deref(),
|
since: since.as_deref(),
|
||||||
full_state: false,
|
|
||||||
set_presence,
|
set_presence,
|
||||||
timeout,
|
timeout,
|
||||||
})
|
}))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let next_batch_clone = response.next_batch.clone();
|
let next_batch_clone = response.next_batch.clone();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user