client-api: Make all pub enums non_exhaustive
This commit is contained in:
parent
1489b5e1f1
commit
ab3d48b576
@ -189,6 +189,7 @@ impl StdError for ResponseDeserializationError {}
|
|||||||
|
|
||||||
/// An error was reported by the server (HTTP status code 4xx or 5xx)
|
/// An error was reported by the server (HTTP status code 4xx or 5xx)
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum ServerError<E> {
|
pub enum ServerError<E> {
|
||||||
/// An error that is expected to happen under certain circumstances and
|
/// An error that is expected to happen under certain circumstances and
|
||||||
/// that has a well-defined structure
|
/// that has a well-defined structure
|
||||||
|
@ -215,6 +215,7 @@ use error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError};
|
|||||||
|
|
||||||
/// An enum to control whether an access token should be added to outgoing requests
|
/// An enum to control whether an access token should be added to outgoing requests
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum SendAccessToken<'a> {
|
pub enum SendAccessToken<'a> {
|
||||||
/// Add the given access token to the request only if the `METADATA` on the request requires it
|
/// Add the given access token to the request only if the `METADATA` on the request requires it
|
||||||
IfRequired(&'a str),
|
IfRequired(&'a str),
|
||||||
@ -371,6 +372,7 @@ pub trait IncomingNonAuthRequest: IncomingRequest {}
|
|||||||
|
|
||||||
/// Authentication scheme used by the endpoint.
|
/// Authentication scheme used by the endpoint.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum AuthScheme {
|
pub enum AuthScheme {
|
||||||
/// No authentication is performed.
|
/// No authentication is performed.
|
||||||
None,
|
None,
|
||||||
|
@ -17,6 +17,7 @@ mod kind_serde;
|
|||||||
|
|
||||||
/// An enum for the error kind. Items may contain additional information.
|
/// An enum for the error kind. Items may contain additional information.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum ErrorKind {
|
pub enum ErrorKind {
|
||||||
/// M_FORBIDDEN
|
/// M_FORBIDDEN
|
||||||
Forbidden,
|
Forbidden,
|
||||||
|
@ -40,8 +40,12 @@ impl<'a> IdentityServerInfo<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Possible values for deleting or unbinding 3PIDs.
|
/// Possible values for deleting or unbinding 3PIDs.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, StringEnum)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "kebab-case")]
|
#[ruma_enum(rename_all = "kebab-case")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum ThirdPartyIdRemovalStatus {
|
pub enum ThirdPartyIdRemovalStatus {
|
||||||
/// Either the homeserver couldn't determine the right identity server to contact, or the
|
/// Either the homeserver couldn't determine the right identity server to contact, or the
|
||||||
/// identity server refused the operation.
|
/// identity server refused the operation.
|
||||||
@ -53,3 +57,10 @@ pub enum ThirdPartyIdRemovalStatus {
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ThirdPartyIdRemovalStatus {
|
||||||
|
/// Creates a string slice from this `ThirdPartyIdRemovalStatus`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -111,6 +111,7 @@ impl Response {
|
|||||||
/// The kind of account being registered.
|
/// The kind of account being registered.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub enum RegistrationKind {
|
pub enum RegistrationKind {
|
||||||
/// A guest account
|
/// A guest account
|
||||||
///
|
///
|
||||||
@ -129,6 +130,7 @@ impl Default for RegistrationKind {
|
|||||||
|
|
||||||
/// The login type.
|
/// The login type.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub enum LoginType {
|
pub enum LoginType {
|
||||||
/// An appservice-specific login type
|
/// An appservice-specific login type
|
||||||
#[serde(rename = "m.login.application_service")]
|
#[serde(rename = "m.login.application_service")]
|
||||||
|
@ -41,6 +41,7 @@ impl RoomKeyBackup {
|
|||||||
/// The algorithm used for storing backups.
|
/// The algorithm used for storing backups.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "algorithm", content = "auth_data")]
|
#[serde(tag = "algorithm", content = "auth_data")]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub enum BackupAlgorithm {
|
pub enum BackupAlgorithm {
|
||||||
/// `m.megolm_backup.v1.curve25519-aes-sha2` backup algorithm.
|
/// `m.megolm_backup.v1.curve25519-aes-sha2` backup algorithm.
|
||||||
#[serde(rename = "m.megolm_backup.v1.curve25519-aes-sha2")]
|
#[serde(rename = "m.megolm_backup.v1.curve25519-aes-sha2")]
|
||||||
|
@ -161,9 +161,13 @@ impl Default for RoomVersionsCapability {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The stability of a room version
|
/// The stability of a room version.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "lowercase")]
|
#[ruma_enum(rename_all = "lowercase")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum RoomVersionStability {
|
pub enum RoomVersionStability {
|
||||||
/// Support for the given version is stable.
|
/// Support for the given version is stable.
|
||||||
Stable,
|
Stable,
|
||||||
@ -175,6 +179,13 @@ pub enum RoomVersionStability {
|
|||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl RoomVersionStability {
|
||||||
|
/// Creates a string slice from this `RoomVersionStability`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -15,8 +15,12 @@ use ruma_serde::{Outgoing, StringEnum};
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
/// Format to use for returned events.
|
/// Format to use for returned events.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum EventFormat {
|
pub enum EventFormat {
|
||||||
/// Client format, as described in the Client API.
|
/// Client format, as described in the Client API.
|
||||||
Client,
|
Client,
|
||||||
@ -28,6 +32,13 @@ pub enum EventFormat {
|
|||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EventFormat {
|
||||||
|
/// Creates a string slice from this `EventFormat`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for EventFormat {
|
impl Default for EventFormat {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Client
|
Self::Client
|
||||||
|
@ -6,6 +6,7 @@ use serde::{ser::SerializeStruct as _, Deserialize, Serialize, Serializer};
|
|||||||
/// [lazy-loading]: https://matrix.org/docs/spec/client_server/r0.6.0#lazy-loading-room-members
|
/// [lazy-loading]: https://matrix.org/docs/spec/client_server/r0.6.0#lazy-loading-room-members
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize)]
|
||||||
#[serde(from = "LazyLoadJsonRepr")]
|
#[serde(from = "LazyLoadJsonRepr")]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum LazyLoadOptions {
|
pub enum LazyLoadOptions {
|
||||||
/// Disables lazy-loading of membership events.
|
/// Disables lazy-loading of membership events.
|
||||||
Disabled,
|
Disabled,
|
||||||
|
@ -5,6 +5,7 @@ use serde::{
|
|||||||
|
|
||||||
/// Options for filtering based on the presence of a URL.
|
/// Options for filtering based on the presence of a URL.
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum UrlFilter {
|
pub enum UrlFilter {
|
||||||
/// Includes only events with a url key in their content.
|
/// Includes only events with a url key in their content.
|
||||||
EventsWithUrl,
|
EventsWithUrl,
|
||||||
|
@ -5,20 +5,6 @@ use ruma_api::ruma_api;
|
|||||||
use ruma_identifiers::{Error, MxcUri, ServerName};
|
use ruma_identifiers::{Error, MxcUri, ServerName};
|
||||||
use ruma_serde::StringEnum;
|
use ruma_serde::StringEnum;
|
||||||
|
|
||||||
/// The desired resizing method.
|
|
||||||
#[derive(Clone, Debug, StringEnum)]
|
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
|
||||||
pub enum Method {
|
|
||||||
/// Crop the original to produce the requested image dimensions.
|
|
||||||
Crop,
|
|
||||||
|
|
||||||
/// Maintain the original aspect ratio of the source image.
|
|
||||||
Scale,
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
|
||||||
_Custom(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
description: "Get a thumbnail of content from the media store.",
|
description: "Get a thumbnail of content from the media store.",
|
||||||
@ -98,3 +84,28 @@ impl Response {
|
|||||||
Self { file, content_type: None }
|
Self { file, content_type: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The desired resizing method.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
|
#[non_exhaustive]
|
||||||
|
pub enum Method {
|
||||||
|
/// Crop the original to produce the requested image dimensions.
|
||||||
|
Crop,
|
||||||
|
|
||||||
|
/// Maintain the original aspect ratio of the source image.
|
||||||
|
Scale,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Method {
|
||||||
|
/// Creates a string slice from this `Method`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -63,8 +63,12 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The kind of membership events to filter for.
|
/// The kind of membership events to filter for.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "lowercase")]
|
#[ruma_enum(rename_all = "lowercase")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum MembershipEventFilter {
|
pub enum MembershipEventFilter {
|
||||||
/// The user has joined.
|
/// The user has joined.
|
||||||
Join,
|
Join,
|
||||||
@ -82,6 +86,13 @@ pub enum MembershipEventFilter {
|
|||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl MembershipEventFilter {
|
||||||
|
/// Creates a string slice from this `MembershipEventFilter`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(all(test, feature = "server"))]
|
#[cfg(all(test, feature = "server"))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
|
@ -121,6 +121,7 @@ fn is_default_limit(val: &UInt) -> bool {
|
|||||||
|
|
||||||
/// The direction to return events from.
|
/// The direction to return events from.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum Direction {
|
pub enum Direction {
|
||||||
/// Return events backwards in time from the requested `from` token.
|
/// Return events backwards in time from the requested `from` token.
|
||||||
#[serde(rename = "b")]
|
#[serde(rename = "b")]
|
||||||
|
@ -159,8 +159,12 @@ impl TryFrom<PushRule> for ConditionalPushRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The kinds of push rules that are available.
|
/// The kinds of push rules that are available.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum RuleKind {
|
pub enum RuleKind {
|
||||||
/// User-configured rules that override all other kinds.
|
/// User-configured rules that override all other kinds.
|
||||||
Override,
|
Override,
|
||||||
@ -181,9 +185,20 @@ pub enum RuleKind {
|
|||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl RuleKind {
|
||||||
|
/// Creates a string slice from this `RuleKind`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Which kind a pusher is.
|
/// Which kind a pusher is.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum PusherKind {
|
pub enum PusherKind {
|
||||||
/// A pusher that sends HTTP pokes.
|
/// A pusher that sends HTTP pokes.
|
||||||
Http,
|
Http,
|
||||||
@ -194,3 +209,10 @@ pub enum PusherKind {
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PusherKind {
|
||||||
|
/// Creates a string slice from this `PusherKind`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -9,8 +9,12 @@ pub mod upgrade_room;
|
|||||||
use ruma_serde::StringEnum;
|
use ruma_serde::StringEnum;
|
||||||
|
|
||||||
/// Whether or not a newly created room will be listed in the room directory.
|
/// Whether or not a newly created room will be listed in the room directory.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum Visibility {
|
pub enum Visibility {
|
||||||
/// Indicates that the room will be shown in the published room list.
|
/// Indicates that the room will be shown in the published room list.
|
||||||
Public,
|
Public,
|
||||||
@ -22,6 +26,13 @@ pub enum Visibility {
|
|||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Visibility {
|
||||||
|
/// Creates a string slice from this `Visibility`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for Visibility {
|
impl Default for Visibility {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::Private
|
Self::Private
|
||||||
|
@ -195,8 +195,12 @@ impl Default for CreationContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A convenience parameter for setting a few default state events.
|
/// A convenience parameter for setting a few default state events.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum RoomPreset {
|
pub enum RoomPreset {
|
||||||
/// `join_rules` is set to `invite` and `history_visibility` is set to `shared`.
|
/// `join_rules` is set to `invite` and `history_visibility` is set to `shared`.
|
||||||
PrivateChat,
|
PrivateChat,
|
||||||
@ -210,3 +214,10 @@ pub enum RoomPreset {
|
|||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl RoomPreset {
|
||||||
|
/// Creates a string slice from this `RoomPreset`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -236,8 +236,12 @@ impl Grouping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The key within events to use for this grouping.
|
/// The key within events to use for this grouping.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
||||||
#[ruma_enum(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum GroupingKey {
|
pub enum GroupingKey {
|
||||||
/// `room_id`
|
/// `room_id`
|
||||||
RoomId,
|
RoomId,
|
||||||
@ -249,6 +253,13 @@ pub enum GroupingKey {
|
|||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GroupingKey {
|
||||||
|
/// Creates a string slice from this `GroupingKey`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Requests that the server partitions the result set based on the provided list of keys.
|
/// Requests that the server partitions the result set based on the provided list of keys.
|
||||||
#[derive(Clone, Default, Debug, Outgoing, Serialize)]
|
#[derive(Clone, Default, Debug, Outgoing, Serialize)]
|
||||||
#[incoming_derive(Default)]
|
#[incoming_derive(Default)]
|
||||||
@ -272,7 +283,11 @@ impl Groupings<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The keys to search for.
|
/// The keys to search for.
|
||||||
|
///
|
||||||
|
/// This type can hold an arbitrary string. To check for formats that are not available as a
|
||||||
|
/// documented variant here, use its string representation, obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum SearchKeys {
|
pub enum SearchKeys {
|
||||||
/// content.body
|
/// content.body
|
||||||
#[ruma_enum(rename = "content.body")]
|
#[ruma_enum(rename = "content.body")]
|
||||||
@ -290,6 +305,13 @@ pub enum SearchKeys {
|
|||||||
_Custom(String),
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SearchKeys {
|
||||||
|
/// Creates a string slice from this `SearchKeys`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The order in which to search for results.
|
/// The order in which to search for results.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
@ -465,6 +487,7 @@ impl UserProfile {
|
|||||||
|
|
||||||
/// Represents either a room or user ID for returning grouped search results.
|
/// Represents either a room or user ID for returning grouped search results.
|
||||||
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum RoomIdOrUserId {
|
pub enum RoomIdOrUserId {
|
||||||
/// Represents a room ID.
|
/// Represents a room ID.
|
||||||
RoomId(RoomId),
|
RoomId(RoomId),
|
||||||
|
@ -78,6 +78,7 @@ impl Response {
|
|||||||
/// Identification information for the user.
|
/// Identification information for the user.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
||||||
#[serde(from = "user_serde::IncomingUserIdentifier", into = "user_serde::UserIdentifier<'_>")]
|
#[serde(from = "user_serde::IncomingUserIdentifier", into = "user_serde::UserIdentifier<'_>")]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum UserIdentifier<'a> {
|
pub enum UserIdentifier<'a> {
|
||||||
/// Either a fully qualified Matrix user ID, or just the localpart (as part of the 'identifier'
|
/// Either a fully qualified Matrix user ID, or just the localpart (as part of the 'identifier'
|
||||||
/// field).
|
/// field).
|
||||||
@ -106,6 +107,7 @@ pub enum UserIdentifier<'a> {
|
|||||||
/// The authentication mechanism.
|
/// The authentication mechanism.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub enum LoginInfo<'a> {
|
pub enum LoginInfo<'a> {
|
||||||
/// An identifier and password are supplied to authenticate.
|
/// An identifier and password are supplied to authenticate.
|
||||||
#[serde(rename = "m.login.password")]
|
#[serde(rename = "m.login.password")]
|
||||||
|
@ -134,6 +134,7 @@ impl Response {
|
|||||||
/// 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, Debug, Outgoing, Serialize)]
|
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Filter<'a> {
|
pub enum Filter<'a> {
|
||||||
// The filter definition needs to be (de)serialized twice because it is a URL-encoded JSON
|
// The filter definition needs to be (de)serialized twice because it is a URL-encoded JSON
|
||||||
@ -146,8 +147,8 @@ pub enum Filter<'a> {
|
|||||||
// FilterDefinition is the first variant, JSON decoding is attempted first which is almost
|
// FilterDefinition is the first variant, JSON decoding is attempted first which is almost
|
||||||
// functionally equivalent to looking at whether the first symbol is a '{' as the spec says.
|
// functionally equivalent to looking at whether the first symbol is a '{' as the spec says.
|
||||||
// (there are probably some corner cases like leading whitespace)
|
// (there are probably some corner cases like leading whitespace)
|
||||||
#[serde(with = "ruma_serde::json_string")]
|
|
||||||
/// A complete filter definition serialized to JSON.
|
/// A complete filter definition serialized to JSON.
|
||||||
|
#[serde(with = "ruma_serde::json_string")]
|
||||||
FilterDefinition(FilterDefinition<'a>),
|
FilterDefinition(FilterDefinition<'a>),
|
||||||
|
|
||||||
/// The ID of a filter saved on the server.
|
/// The ID of a filter saved on the server.
|
||||||
|
@ -53,6 +53,7 @@ impl Response {
|
|||||||
/// A mark for whether the user is typing within a length of time or not.
|
/// A mark for whether the user is typing within a length of time or not.
|
||||||
#[derive(Clone, Copy, Debug, Serialize)]
|
#[derive(Clone, Copy, Debug, Serialize)]
|
||||||
#[serde(into = "TypingInner")]
|
#[serde(into = "TypingInner")]
|
||||||
|
#[allow(clippy::exhaustive_enums)]
|
||||||
pub enum Typing {
|
pub enum Typing {
|
||||||
/// Not typing.
|
/// Not typing.
|
||||||
No,
|
No,
|
||||||
|
@ -116,6 +116,7 @@ impl AuthFlow {
|
|||||||
|
|
||||||
/// Contains either a User-Interactive Authentication API response body or a Matrix error.
|
/// Contains either a User-Interactive Authentication API response body or a Matrix error.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub enum UiaaResponse {
|
pub enum UiaaResponse {
|
||||||
/// User-Interactive Authentication API response
|
/// User-Interactive Authentication API response
|
||||||
AuthResponse(UiaaInfo),
|
AuthResponse(UiaaInfo),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user