Allow custom values for more enums
This commit is contained in:
parent
70a12864ef
commit
d34a270919
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
* Update strum dependency to 0.19
|
|
||||||
* The `EndpointError` trait now requires `std::error::Error`. This allows integrating
|
* The `EndpointError` trait now requires `std::error::Error`. This allows integrating
|
||||||
`EndpointError`s in the common rust error ecosystem like `thiserror` and `anyhow`.
|
`EndpointError`s in the common rust error ecosystem like `thiserror` and `anyhow`.
|
||||||
* The `Endpoint` trait has been replaced by two new traits that each capture a subset of its
|
* The `Endpoint` trait has been replaced by two new traits that each capture a subset of its
|
||||||
|
@ -24,7 +24,6 @@ ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
|||||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||||
serde = { version = "1.0.114", features = ["derive"] }
|
serde = { version = "1.0.114", features = ["derive"] }
|
||||||
serde_json = "1.0.57"
|
serde_json = "1.0.57"
|
||||||
strum = "0.19.2"
|
|
||||||
thiserror = "1.0.20"
|
thiserror = "1.0.20"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -201,10 +201,6 @@ pub enum DeserializationError {
|
|||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Ident(#[from] ruma_identifiers::Error),
|
Ident(#[from] ruma_identifiers::Error),
|
||||||
|
|
||||||
/// Path segment deserialization failed.
|
|
||||||
#[error("{0}")]
|
|
||||||
Strum(#[from] strum::ParseError),
|
|
||||||
|
|
||||||
/// Header value deserialization failed.
|
/// Header value deserialization failed.
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Header(#[from] http::header::ToStrError),
|
Header(#[from] http::header::ToStrError),
|
||||||
|
@ -29,7 +29,6 @@ ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
|||||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||||
serde = { version = "1.0.114", features = ["derive"] }
|
serde = { version = "1.0.114", features = ["derive"] }
|
||||||
serde_json = "1.0.57"
|
serde_json = "1.0.57"
|
||||||
strum = { version = "0.19.2", features = ["derive"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_identifiers::{ServerNameBox, UserId};
|
use ruma_identifiers::{ServerNameBox, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -61,9 +61,11 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Access token types.
|
/// Access token types.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum TokenType {
|
pub enum TokenType {
|
||||||
/// Bearer token type
|
/// Bearer token type
|
||||||
Bearer,
|
Bearer,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use maplit::btreemap;
|
use maplit::btreemap;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_identifiers::RoomVersionId;
|
use ruma_identifiers::RoomVersionId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value as JsonValue;
|
use serde_json::Value as JsonValue;
|
||||||
@ -150,14 +151,15 @@ impl Default for RoomVersionsCapability {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The stability of a room version
|
/// The stability of a room version
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "lowercase")]
|
||||||
pub enum RoomVersionStability {
|
pub enum RoomVersionStability {
|
||||||
/// Support for the given version is stable.
|
/// Support for the given version is stable.
|
||||||
#[serde(rename = "stable")]
|
|
||||||
Stable,
|
Stable,
|
||||||
|
|
||||||
/// Support for the given version is unstable.
|
/// Support for the given version is unstable.
|
||||||
#[serde(rename = "unstable")]
|
|
||||||
Unstable,
|
Unstable,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,22 @@ pub use lazy_load::LazyLoadOptions;
|
|||||||
pub use url::UrlFilter;
|
pub use url::UrlFilter;
|
||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::Outgoing;
|
use ruma_common::{Outgoing, StringEnum};
|
||||||
use ruma_identifiers::{RoomId, UserId};
|
use ruma_identifiers::{RoomId, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
|
||||||
/// Format to use for returned events.
|
/// Format to use for returned events.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
pub enum EventFormat {
|
pub enum EventFormat {
|
||||||
/// Client format, as described in the Client API.
|
/// Client format, as described in the Client API.
|
||||||
Client,
|
Client,
|
||||||
|
|
||||||
/// Raw events from federation.
|
/// Raw events from federation.
|
||||||
Federation,
|
Federation,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for EventFormat {
|
impl Default for EventFormat {
|
||||||
@ -292,7 +294,7 @@ impl IncomingFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A filter definition
|
/// A filter definition
|
||||||
#[derive(Clone, Copy, Debug, Default, Outgoing, Serialize)]
|
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[incoming_derive(Clone, Default, Serialize)]
|
#[incoming_derive(Clone, Default, Serialize)]
|
||||||
pub struct FilterDefinition<'a> {
|
pub struct FilterDefinition<'a> {
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
//! [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-members)
|
//! [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-members)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::Raw;
|
use ruma_common::{Raw, StringEnum};
|
||||||
use ruma_events::room::member::MemberEvent;
|
use ruma_events::room::member::MemberEvent;
|
||||||
use ruma_identifiers::RoomId;
|
use ruma_identifiers::RoomId;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -64,9 +63,8 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The kind of membership events to filter for.
|
/// The kind of membership events to filter for.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "lowercase")]
|
||||||
#[serde(rename_all = "lowercase")]
|
|
||||||
pub enum MembershipEventFilter {
|
pub enum MembershipEventFilter {
|
||||||
/// The user has joined.
|
/// The user has joined.
|
||||||
Join,
|
Join,
|
||||||
@ -79,6 +77,9 @@ pub enum MembershipEventFilter {
|
|||||||
|
|
||||||
/// The user has been banned.
|
/// The user has been banned.
|
||||||
Ban,
|
Ban,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
//! Endpoints for push notifications.
|
//! Endpoints for push notifications.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use ruma_common::{push::PusherData, StringEnum};
|
||||||
|
|
||||||
use ruma_common::push::PusherData;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
pub mod delete_pushrule;
|
pub mod delete_pushrule;
|
||||||
pub mod get_notifications;
|
pub mod get_notifications;
|
||||||
@ -20,12 +17,8 @@ pub mod set_pushrule_actions;
|
|||||||
pub mod set_pushrule_enabled;
|
pub mod set_pushrule_enabled;
|
||||||
|
|
||||||
/// The kinds of push rules that are available
|
/// The kinds of push rules that are available
|
||||||
#[derive(
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
||||||
Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Display, EnumString,
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
)]
|
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum RuleKind {
|
pub enum RuleKind {
|
||||||
/// User-configured rules that override all other kinds
|
/// User-configured rules that override all other kinds
|
||||||
Override,
|
Override,
|
||||||
@ -41,14 +34,9 @@ pub enum RuleKind {
|
|||||||
|
|
||||||
/// Content-specific rules
|
/// Content-specific rules
|
||||||
Content,
|
Content,
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<&'_ str> for RuleKind {
|
#[doc(hidden)]
|
||||||
type Error = strum::ParseError;
|
_Custom(String),
|
||||||
|
|
||||||
fn try_from(s: &str) -> Result<Self, Self::Error> {
|
|
||||||
s.parse()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Defines a pusher
|
/// Defines a pusher
|
||||||
@ -82,12 +70,15 @@ pub struct Pusher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Which kind a pusher is
|
/// Which kind a pusher is
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
pub enum PusherKind {
|
pub enum PusherKind {
|
||||||
/// A pusher that sends HTTP pokes.
|
/// A pusher that sends HTTP pokes.
|
||||||
Http,
|
Http,
|
||||||
|
|
||||||
/// A pusher that emails the user with unread notifications.
|
/// A pusher that emails the user with unread notifications.
|
||||||
Email,
|
Email,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
//! [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid)
|
//! [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid)
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
use ruma_common::{AsRefStr, DisplayAsRefStr, FromString};
|
||||||
use ruma_identifiers::{EventId, RoomId};
|
use ruma_identifiers::{EventId, RoomId};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -51,18 +49,12 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The type of receipt.
|
/// The type of receipt.
|
||||||
#[derive(Clone, Copy, Debug, Display, EnumString)]
|
#[derive(Clone, Debug, AsRefStr, DisplayAsRefStr, FromString)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum ReceiptType {
|
pub enum ReceiptType {
|
||||||
/// m.read
|
/// m.read
|
||||||
#[strum(serialize = "m.read")]
|
#[ruma_enum(rename = "m.read")]
|
||||||
Read,
|
Read,
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<&'_ str> for ReceiptType {
|
#[doc(hidden)]
|
||||||
type Error = strum::ParseError;
|
_Custom(String),
|
||||||
|
|
||||||
fn try_from(s: &str) -> Result<Self, Self::Error> {
|
|
||||||
s.parse()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,20 @@ pub mod get_room_event;
|
|||||||
pub mod report_content;
|
pub mod report_content;
|
||||||
pub mod upgrade_room;
|
pub mod upgrade_room;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use ruma_common::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.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
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,
|
||||||
|
|
||||||
/// Indicates that the room will not be shown in the published room list.
|
/// Indicates that the room will not be shown in the published room list.
|
||||||
Private,
|
Private,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Visibility {
|
impl Default for Visibility {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use assign::assign;
|
use assign::assign;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::Raw;
|
use ruma_common::{Raw, StringEnum};
|
||||||
use ruma_events::{
|
use ruma_events::{
|
||||||
room::{
|
room::{
|
||||||
create::{CreateEventContent, PreviousRoom},
|
create::{CreateEventContent, PreviousRoom},
|
||||||
@ -160,9 +160,8 @@ impl Default for CreationContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A convenience parameter for setting a few default state events.
|
/// A convenience parameter for setting a few default state events.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
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,
|
||||||
@ -172,4 +171,7 @@ pub enum RoomPreset {
|
|||||||
|
|
||||||
/// Same as `PrivateChat`, but all initial invitees get the same power level as the creator.
|
/// Same as `PrivateChat`, but all initial invitees get the same power level as the creator.
|
||||||
TrustedPrivateChat,
|
TrustedPrivateChat,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use js_int::{uint, UInt};
|
use js_int::{uint, UInt};
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::{Outgoing, Raw};
|
use ruma_common::{Outgoing, Raw, StringEnum};
|
||||||
use ruma_events::{AnyRoomEvent, AnyStateEvent};
|
use ruma_events::{AnyRoomEvent, AnyStateEvent};
|
||||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -71,7 +71,7 @@ impl Categories<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Criteria for searching a category of events.
|
/// Criteria for searching a category of events.
|
||||||
#[derive(Clone, Copy, Debug, Outgoing, Serialize)]
|
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct Criteria<'a> {
|
pub struct Criteria<'a> {
|
||||||
/// The string to search events for.
|
/// The string to search events for.
|
||||||
@ -216,7 +216,7 @@ impl EventContextResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A grouping for partioning the result set.
|
/// A grouping for partioning the result set.
|
||||||
#[derive(Clone, Copy, Default, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct Grouping {
|
pub struct Grouping {
|
||||||
/// The key within events to use for this grouping.
|
/// The key within events to use for this grouping.
|
||||||
@ -236,15 +236,17 @@ impl Grouping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The key within events to use for this grouping.
|
/// The key within events to use for this grouping.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, PartialOrd, Ord, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
pub enum GroupingKey {
|
pub enum GroupingKey {
|
||||||
/// `room_id`
|
/// `room_id`
|
||||||
RoomId,
|
RoomId,
|
||||||
|
|
||||||
/// `sender`
|
/// `sender`
|
||||||
Sender,
|
Sender,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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.
|
||||||
@ -270,26 +272,28 @@ impl Groupings<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The keys to search for.
|
/// The keys to search for.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum SearchKeys {
|
pub enum SearchKeys {
|
||||||
/// content.body
|
/// content.body
|
||||||
#[serde(rename = "content.body")]
|
#[ruma_enum(rename = "content.body")]
|
||||||
ContentBody,
|
ContentBody,
|
||||||
|
|
||||||
/// content.name
|
/// content.name
|
||||||
#[serde(rename = "content.name")]
|
#[ruma_enum(rename = "content.name")]
|
||||||
ContentName,
|
ContentName,
|
||||||
|
|
||||||
/// content.topic
|
/// content.topic
|
||||||
#[serde(rename = "content.topic")]
|
#[ruma_enum(rename = "content.topic")]
|
||||||
ContentTopic,
|
ContentTopic,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The order in which to search for results.
|
/// The order in which to search for results.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
pub enum OrderBy {
|
pub enum OrderBy {
|
||||||
/// Prioritize recent events.
|
/// Prioritize recent events.
|
||||||
Recent,
|
Recent,
|
||||||
@ -297,6 +301,9 @@ pub enum OrderBy {
|
|||||||
/// Prioritize events by a numerical ranking of how closely they matched the search
|
/// Prioritize events by a numerical ranking of how closely they matched the search
|
||||||
/// criteria.
|
/// criteria.
|
||||||
Rank,
|
Rank,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Categories of events that can be searched for.
|
/// Categories of events that can be searched for.
|
||||||
|
@ -78,7 +78,7 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Identification information for the user.
|
/// Identification information for the user.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
||||||
#[serde(from = "user_serde::IncomingUserInfo", into = "user_serde::UserInfo")]
|
#[serde(from = "user_serde::IncomingUserInfo", into = "user_serde::UserInfo")]
|
||||||
pub enum UserInfo<'a> {
|
pub enum UserInfo<'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'
|
||||||
|
@ -29,7 +29,7 @@ ruma_api! {
|
|||||||
/// 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")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub filter: Option<Filter<'a>>,
|
pub filter: Option<&'a Filter<'a>>,
|
||||||
|
|
||||||
/// A point in time to continue a sync from.
|
/// A point in time to continue a sync from.
|
||||||
///
|
///
|
||||||
@ -45,9 +45,11 @@ ruma_api! {
|
|||||||
pub full_state: bool,
|
pub full_state: bool,
|
||||||
|
|
||||||
/// Controls whether the client is automatically marked as online by polling this API.
|
/// Controls whether the client is automatically marked as online by polling this API.
|
||||||
|
///
|
||||||
|
/// Defaults to `PresenceState::Online`.
|
||||||
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub set_presence: PresenceState,
|
pub set_presence: &'a PresenceState,
|
||||||
|
|
||||||
/// The maximum time to poll in milliseconds before returning this request.
|
/// The maximum time to poll in milliseconds before returning this request.
|
||||||
#[serde(
|
#[serde(
|
||||||
@ -117,7 +119,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, Copy, Debug, Outgoing, Serialize)]
|
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum Filter<'a> {
|
pub enum Filter<'a> {
|
||||||
@ -539,10 +541,10 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn serialize_all_params() {
|
fn serialize_all_params() {
|
||||||
let req: http::Request<Vec<u8>> = Request {
|
let req: http::Request<Vec<u8>> = Request {
|
||||||
filter: Some(Filter::FilterId("66696p746572")),
|
filter: Some(&Filter::FilterId("66696p746572")),
|
||||||
since: Some("s72594_4483_1934"),
|
since: Some("s72594_4483_1934"),
|
||||||
full_state: true,
|
full_state: true,
|
||||||
set_presence: PresenceState::Offline,
|
set_presence: &PresenceState::Offline,
|
||||||
timeout: Some(Duration::from_millis(30000)),
|
timeout: Some(Duration::from_millis(30000)),
|
||||||
}
|
}
|
||||||
.try_into_http_request("https://homeserver.tld", Some("auth_tok"))
|
.try_into_http_request("https://homeserver.tld", Some("auth_tok"))
|
||||||
|
@ -18,16 +18,18 @@ async fn log_messages(homeserver_url: Uri, username: &str, password: &str) -> an
|
|||||||
|
|
||||||
client.log_in(username, password, None, None).await?;
|
client.log_in(username, password, None, None).await?;
|
||||||
|
|
||||||
|
// FIXME: Possibly promotable when replacing `.into()` if `ignore_all` is made const.
|
||||||
|
let filter = FilterDefinition::ignore_all().into();
|
||||||
let initial_sync_response = client
|
let initial_sync_response = client
|
||||||
.request(assign!(sync_events::Request::new(), {
|
.request(assign!(sync_events::Request::new(), {
|
||||||
filter: Some(FilterDefinition::ignore_all().into()),
|
filter: Some(&filter),
|
||||||
}))
|
}))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut sync_stream = Box::pin(client.sync(
|
let mut sync_stream = Box::pin(client.sync(
|
||||||
None,
|
None,
|
||||||
initial_sync_response.next_batch,
|
initial_sync_response.next_batch,
|
||||||
PresenceState::Online,
|
&PresenceState::Online,
|
||||||
Some(Duration::from_secs(30)),
|
Some(Duration::from_secs(30)),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
//! let mut sync_stream = Box::pin(client.sync(
|
//! let mut sync_stream = Box::pin(client.sync(
|
||||||
//! None,
|
//! None,
|
||||||
//! next_batch_token,
|
//! next_batch_token,
|
||||||
//! PresenceState::Online,
|
//! &PresenceState::Online,
|
||||||
//! Some(Duration::from_secs(30)),
|
//! Some(Duration::from_secs(30)),
|
||||||
//! ));
|
//! ));
|
||||||
//! while let Some(response) = sync_stream.try_next().await? {
|
//! while let Some(response) = sync_stream.try_next().await? {
|
||||||
@ -281,9 +281,9 @@ impl Client {
|
|||||||
/// Convenience method that represents repeated calls to the sync_events endpoint as a stream.
|
/// Convenience method that represents repeated calls to the sync_events endpoint as a stream.
|
||||||
pub fn sync<'a>(
|
pub fn sync<'a>(
|
||||||
&self,
|
&self,
|
||||||
filter: Option<SyncFilter<'a>>,
|
filter: Option<&'a SyncFilter<'a>>,
|
||||||
since: String,
|
since: String,
|
||||||
set_presence: ruma_common::presence::PresenceState,
|
set_presence: &'a ruma_common::presence::PresenceState,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
) -> impl Stream<Item = Result<SyncResponse, Error<ruma_client_api::Error>>>
|
) -> impl Stream<Item = Result<SyncResponse, Error<ruma_client_api::Error>>>
|
||||||
+ TryStream<Ok = SyncResponse, Error = Error<ruma_client_api::Error>>
|
+ TryStream<Ok = SyncResponse, Error = Error<ruma_client_api::Error>>
|
||||||
|
@ -17,7 +17,6 @@ ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
|||||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||||
serde = { version = "1.0.114", features = ["derive"] }
|
serde = { version = "1.0.114", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.57", features = ["raw_value"] }
|
serde_json = { version = "1.0.57", features = ["raw_value"] }
|
||||||
strum = { version = "0.19.2", features = ["derive"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
matches = "0.1.8"
|
matches = "0.1.8"
|
||||||
|
@ -2,14 +2,11 @@
|
|||||||
//!
|
//!
|
||||||
//! [presence]: https://matrix.org/docs/spec/client_server/r0.6.1#id62
|
//! [presence]: https://matrix.org/docs/spec/client_server/r0.6.1#id62
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use crate::StringEnum;
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
/// A description of a user's connectivity and availability for chat.
|
/// A description of a user's connectivity and availability for chat.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum PresenceState {
|
pub enum PresenceState {
|
||||||
/// Disconnected from the service.
|
/// Disconnected from the service.
|
||||||
Offline,
|
Offline,
|
||||||
@ -19,6 +16,9 @@ pub enum PresenceState {
|
|||||||
|
|
||||||
/// Connected to the service but not available for chat.
|
/// Connected to the service but not available for chat.
|
||||||
Unavailable,
|
Unavailable,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PresenceState {
|
impl Default for PresenceState {
|
||||||
@ -26,3 +26,9 @@ impl Default for PresenceState {
|
|||||||
Self::Online
|
Self::Online
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for &'_ PresenceState {
|
||||||
|
fn default() -> Self {
|
||||||
|
&PresenceState::Online
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! [push]: https://matrix.org/docs/spec/client_server/r0.6.1#id89
|
//! [push]: https://matrix.org/docs/spec/client_server/r0.6.1#id89
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
mod action;
|
mod action;
|
||||||
@ -237,10 +238,12 @@ impl PusherData {
|
|||||||
/// Currently, only "event_id_only" is supported as of [Push Gateway API r0.1.1][spec].
|
/// Currently, only "event_id_only" is supported as of [Push Gateway API r0.1.1][spec].
|
||||||
///
|
///
|
||||||
/// [spec]: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
|
/// [spec]: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
pub enum PushFormat {
|
pub enum PushFormat {
|
||||||
/// Require the homeserver to only send a reduced set of fields in the push.
|
/// Require the homeserver to only send a reduced set of fields in the push.
|
||||||
EventIdOnly,
|
EventIdOnly,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_identifiers::{RoomAliasId, UserId};
|
use ruma_identifiers::{RoomAliasId, UserId};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -190,13 +191,15 @@ impl User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The medium of a third party identifier.
|
/// The medium of a third party identifier.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "lowercase")]
|
||||||
#[serde(rename_all = "lowercase")]
|
|
||||||
pub enum Medium {
|
pub enum Medium {
|
||||||
/// Email address identifier
|
/// Email address identifier
|
||||||
Email,
|
Email,
|
||||||
|
|
||||||
/// Phone number identifier
|
/// Phone number identifier
|
||||||
MSISDN,
|
MSISDN,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
|||||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||||
serde = { version = "1.0.114", features = ["derive"] }
|
serde = { version = "1.0.114", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.57", features = ["raw_value"] }
|
serde_json = { version = "1.0.57", features = ["raw_value"] }
|
||||||
strum = { version = "0.19.2", features = ["derive"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
//!
|
//!
|
||||||
//! This module also contains types shared by events in its child namespaces.
|
//! This module also contains types shared by events in its child namespaces.
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
pub mod answer;
|
pub mod answer;
|
||||||
pub mod candidates;
|
pub mod candidates;
|
||||||
@ -30,14 +30,15 @@ impl SessionDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The type of VoIP session description.
|
/// The type of VoIP session description.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum SessionDescriptionType {
|
pub enum SessionDescriptionType {
|
||||||
/// An answer.
|
/// An answer.
|
||||||
Answer,
|
Answer,
|
||||||
|
|
||||||
/// An offer.
|
/// An offer.
|
||||||
Offer,
|
Offer,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
//! Types for the *m.call.hangup* event.
|
//! Types for the *m.call.hangup* event.
|
||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_events_macros::MessageEventContent;
|
use ruma_events_macros::MessageEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
use crate::MessageEvent;
|
use crate::MessageEvent;
|
||||||
|
|
||||||
@ -31,14 +31,15 @@ pub struct HangupEventContent {
|
|||||||
/// This should not be provided when the user naturally ends or rejects the call. When there was an
|
/// This should not be provided when the user naturally ends or rejects the call. When there was an
|
||||||
/// error in the call negotiation, this should be `ice_failed` for when ICE negotiation fails or
|
/// error in the call negotiation, this should be `ice_failed` for when ICE negotiation fails or
|
||||||
/// `invite_timeout` for when the other party did not answer in time.
|
/// `invite_timeout` for when the other party did not answer in time.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum Reason {
|
pub enum Reason {
|
||||||
/// ICE negotiation failure.
|
/// ICE negotiation failure.
|
||||||
IceFailed,
|
IceFailed,
|
||||||
|
|
||||||
/// Party did not answer in time.
|
/// Party did not answer in time.
|
||||||
InviteTimeout,
|
InviteTimeout,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ use ruma_common::StringEnum;
|
|||||||
// FIXME: Add `m.foo.bar` or `m.foo_bar` as a naming scheme in StringEnum and remove most rename
|
// FIXME: Add `m.foo.bar` or `m.foo_bar` as a naming scheme in StringEnum and remove most rename
|
||||||
// attributes.
|
// attributes.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum EventType {
|
pub enum EventType {
|
||||||
/// m.call.answer
|
/// m.call.answer
|
||||||
#[ruma_enum(rename = "m.call.answer")]
|
#[ruma_enum(rename = "m.call.answer")]
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! This module also contains types shared by events in its child namespaces.
|
//! This module also contains types shared by events in its child namespaces.
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use ruma_common::StringEnum;
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
pub mod accept;
|
pub mod accept;
|
||||||
pub mod cancel;
|
pub mod cancel;
|
||||||
@ -13,62 +12,67 @@ pub mod request;
|
|||||||
pub mod start;
|
pub mod start;
|
||||||
|
|
||||||
/// A hash algorithm.
|
/// A hash algorithm.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum HashAlgorithm {
|
pub enum HashAlgorithm {
|
||||||
/// The SHA256 hash algorithm.
|
/// The SHA256 hash algorithm.
|
||||||
Sha256,
|
Sha256,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A key agreement protocol.
|
/// A key agreement protocol.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "kebab-case")]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
#[strum(serialize_all = "kebab-case")]
|
|
||||||
pub enum KeyAgreementProtocol {
|
pub enum KeyAgreementProtocol {
|
||||||
/// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol.
|
/// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol.
|
||||||
Curve25519,
|
Curve25519,
|
||||||
|
|
||||||
/// The Curve25519 key agreement protocol with check for public keys.
|
/// The Curve25519 key agreement protocol with check for public keys.
|
||||||
Curve25519HkdfSha256,
|
Curve25519HkdfSha256,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A message authentication code algorithm.
|
/// A message authentication code algorithm.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "kebab-case")]
|
||||||
#[serde(rename_all = "kebab-case")]
|
|
||||||
#[strum(serialize_all = "kebab-case")]
|
|
||||||
pub enum MessageAuthenticationCode {
|
pub enum MessageAuthenticationCode {
|
||||||
/// The HKDF-HMAC-SHA256 MAC.
|
/// The HKDF-HMAC-SHA256 MAC.
|
||||||
HkdfHmacSha256,
|
HkdfHmacSha256,
|
||||||
|
|
||||||
/// The HMAC-SHA256 MAC.
|
/// The HMAC-SHA256 MAC.
|
||||||
HmacSha256,
|
HmacSha256,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Short Authentication String method.
|
/// A Short Authentication String method.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum ShortAuthenticationString {
|
pub enum ShortAuthenticationString {
|
||||||
/// The decimal method.
|
/// The decimal method.
|
||||||
Decimal,
|
Decimal,
|
||||||
|
|
||||||
/// The emoji method.
|
/// The emoji method.
|
||||||
Emoji,
|
Emoji,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Short Authentication String (SAS) verification method.
|
/// A Short Authentication String (SAS) verification method.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum VerificationMethod {
|
pub enum VerificationMethod {
|
||||||
/// The *m.sas.v1* verification method.
|
/// The *m.sas.v1* verification method.
|
||||||
#[serde(rename = "m.sas.v1")]
|
#[ruma_enum(rename = "m.sas.v1")]
|
||||||
#[strum(serialize = "m.sas.v1")]
|
|
||||||
MSasV1,
|
MSasV1,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -36,7 +36,6 @@ pub struct CancelEventContent {
|
|||||||
/// obtained through `.as_str()`.
|
/// obtained through `.as_str()`.
|
||||||
// FIXME: Add `m.foo_bar` as a naming scheme in StringEnum and remove rename attributes.
|
// FIXME: Add `m.foo_bar` as a naming scheme in StringEnum and remove rename attributes.
|
||||||
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum CancelCode {
|
pub enum CancelCode {
|
||||||
/// The user cancelled the verification.
|
/// The user cancelled the verification.
|
||||||
#[ruma_enum(rename = "m.user")]
|
#[ruma_enum(rename = "m.user")]
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
//! Modules and types for events in the *m.policy.rule* namespace.
|
//! Modules and types for events in the *m.policy.rule* namespace.
|
||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use ruma_common::StringEnum;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub mod room;
|
pub mod room;
|
||||||
@ -30,31 +29,19 @@ impl PolicyRuleEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Rules recommendations
|
/// Rules recommendations
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum Recommendation {
|
pub enum Recommendation {
|
||||||
/// Entities affected by the rule should be banned from participation where possible.
|
/// Entities affected by the rule should be banned from participation where possible.
|
||||||
#[serde(rename = "m.ban")]
|
#[ruma_enum(rename = "m.ban")]
|
||||||
Ban,
|
Ban,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Recommendation {
|
impl Recommendation {
|
||||||
/// Creates a string slice from this `Recommendation`.
|
/// Creates a string slice from this `Recommendation`.
|
||||||
pub fn as_str(&self) -> &str {
|
pub fn as_str(&self) -> &str {
|
||||||
match *self {
|
self.as_ref()
|
||||||
Recommendation::Ban => "m.ban",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for Recommendation {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
|
||||||
f.write_str(self.as_str())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Recommendation> for String {
|
|
||||||
fn from(recommendation: Recommendation) -> String {
|
|
||||||
recommendation.to_string()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//! Types for the *m.room.guest_access* event.
|
//! Types for the *m.room.guest_access* event.
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
use crate::StateEvent;
|
use crate::StateEvent;
|
||||||
|
|
||||||
@ -29,14 +29,15 @@ impl GuestAccessEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A policy for guest user access to a room.
|
/// A policy for guest user access to a room.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum GuestAccess {
|
pub enum GuestAccess {
|
||||||
/// Guests are allowed to join the room.
|
/// Guests are allowed to join the room.
|
||||||
CanJoin,
|
CanJoin,
|
||||||
|
|
||||||
/// Guests are not allowed to join the room.
|
/// Guests are not allowed to join the room.
|
||||||
Forbidden,
|
Forbidden,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//! Types for the *m.room.history_visibility* event.
|
//! Types for the *m.room.history_visibility* event.
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
use crate::StateEvent;
|
use crate::StateEvent;
|
||||||
|
|
||||||
@ -28,10 +28,8 @@ impl HistoryVisibilityEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Who can see a room's history.
|
/// Who can see a room's history.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum HistoryVisibility {
|
pub enum HistoryVisibility {
|
||||||
/// Previous events are accessible to newly joined members from the point they were invited
|
/// Previous events are accessible to newly joined members from the point they were invited
|
||||||
/// onwards. Events stop being accessible when the member's state changes to something other
|
/// onwards. Events stop being accessible when the member's state changes to something other
|
||||||
@ -50,4 +48,7 @@ pub enum HistoryVisibility {
|
|||||||
/// All events while this is the `HistoryVisibility` value may be shared by any
|
/// All events while this is the `HistoryVisibility` value may be shared by any
|
||||||
/// participating homeserver with anyone, regardless of whether they have ever joined the room.
|
/// participating homeserver with anyone, regardless of whether they have ever joined the room.
|
||||||
WorldReadable,
|
WorldReadable,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//! Types for the *m.room.join_rules* event.
|
//! Types for the *m.room.join_rules* event.
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
use crate::StateEvent;
|
use crate::StateEvent;
|
||||||
|
|
||||||
@ -27,10 +27,8 @@ impl JoinRulesEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The rule used for users wishing to join this room.
|
/// The rule used for users wishing to join this room.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "lowercase")]
|
||||||
#[serde(rename_all = "lowercase")]
|
|
||||||
#[strum(serialize_all = "lowercase")]
|
|
||||||
pub enum JoinRule {
|
pub enum JoinRule {
|
||||||
/// A user who wishes to join the room must first receive an invite to the room from someone
|
/// A user who wishes to join the room must first receive an invite to the room from someone
|
||||||
/// already inside of the room.
|
/// already inside of the room.
|
||||||
@ -44,4 +42,7 @@ pub enum JoinRule {
|
|||||||
|
|
||||||
/// Anyone can join the room without any prior action.
|
/// Anyone can join the room without any prior action.
|
||||||
Public,
|
Public,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_events_macros::StateEventContent;
|
use ruma_events_macros::StateEventContent;
|
||||||
use ruma_identifiers::{ServerKeyId, ServerNameBox, UserId};
|
use ruma_identifiers::{ServerKeyId, ServerNameBox, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
use crate::{StateEvent, StrippedStateEvent, SyncStateEvent};
|
use crate::{StateEvent, StrippedStateEvent, SyncStateEvent};
|
||||||
|
|
||||||
@ -64,10 +64,8 @@ pub struct MemberEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The membership state of a user.
|
/// The membership state of a user.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "lowercase")]
|
||||||
#[serde(rename_all = "lowercase")]
|
|
||||||
#[strum(serialize_all = "lowercase")]
|
|
||||||
pub enum MembershipState {
|
pub enum MembershipState {
|
||||||
/// The user is banned.
|
/// The user is banned.
|
||||||
Ban,
|
Ban,
|
||||||
@ -83,6 +81,9 @@ pub enum MembershipState {
|
|||||||
|
|
||||||
/// The user has left.
|
/// The user has left.
|
||||||
Leave,
|
Leave,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about a third party invitation.
|
/// Information about a third party invitation.
|
||||||
@ -187,7 +188,7 @@ fn membership_change(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match (prev_content.membership, &content.membership) {
|
match (&prev_content.membership, &content.membership) {
|
||||||
(St::Invite, St::Invite) | (St::Leave, St::Leave) | (St::Ban, St::Ban) => Ch::None,
|
(St::Invite, St::Invite) | (St::Leave, St::Leave) | (St::Ban, St::Ban) => Ch::None,
|
||||||
(St::Invite, St::Join) | (St::Leave, St::Join) => Ch::Joined,
|
(St::Invite, St::Join) | (St::Leave, St::Join) => Ch::Joined,
|
||||||
(St::Invite, St::Leave) => {
|
(St::Invite, St::Leave) => {
|
||||||
@ -213,7 +214,7 @@ fn membership_change(
|
|||||||
(St::Join, St::Ban) => Ch::KickedAndBanned,
|
(St::Join, St::Ban) => Ch::KickedAndBanned,
|
||||||
(St::Leave, St::Invite) => Ch::Invited,
|
(St::Leave, St::Invite) => Ch::Invited,
|
||||||
(St::Ban, St::Leave) => Ch::Unbanned,
|
(St::Ban, St::Leave) => Ch::Unbanned,
|
||||||
(St::Knock, _) | (_, St::Knock) => Ch::NotImplemented,
|
_ => Ch::NotImplemented,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,24 +287,28 @@ pub struct ServerNoticeMessageEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Types of server notices.
|
/// Types of server notices.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum ServerNoticeType {
|
pub enum ServerNoticeType {
|
||||||
/// The server has exceeded some limit which requires the server administrator to intervene.
|
/// The server has exceeded some limit which requires the server administrator to intervene.
|
||||||
#[serde(rename = "m.server_notice.usage_limit_reached")]
|
#[ruma_enum(rename = "m.server_notice.usage_limit_reached")]
|
||||||
UsageLimitReached,
|
UsageLimitReached,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Types of usage limits.
|
/// Types of usage limits.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
pub enum LimitType {
|
pub enum LimitType {
|
||||||
/// The server's number of active users in the last 30 days has exceeded the maximum.
|
/// The server's number of active users in the last 30 days has exceeded the maximum.
|
||||||
///
|
///
|
||||||
/// New connections are being refused by the server. What defines "active" is left as an
|
/// New connections are being refused by the server. What defines "active" is left as an
|
||||||
/// implementation detail, however servers are encouraged to treat syncing users as "active".
|
/// implementation detail, however servers are encouraged to treat syncing users as "active".
|
||||||
MonthlyActiveUser,
|
MonthlyActiveUser,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The format for the formatted representation of a message body.
|
/// The format for the formatted representation of a message body.
|
||||||
@ -313,7 +317,6 @@ pub enum LimitType {
|
|||||||
/// available as a documented variant here, use its string representation,
|
/// available as a documented variant here, use its string representation,
|
||||||
/// obtained through `.as_str()`.
|
/// obtained through `.as_str()`.
|
||||||
#[derive(Clone, Debug, StringEnum)]
|
#[derive(Clone, Debug, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum MessageFormat {
|
pub enum MessageFormat {
|
||||||
/// HTML.
|
/// HTML.
|
||||||
#[ruma_enum(rename = "org.matrix.custom.html")]
|
#[ruma_enum(rename = "org.matrix.custom.html")]
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
//! Types for the *m.room.message.feedback* event.
|
//! Types for the *m.room.message.feedback* event.
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_events_macros::MessageEventContent;
|
use ruma_events_macros::MessageEventContent;
|
||||||
use ruma_identifiers::EventId;
|
use ruma_identifiers::EventId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
use crate::MessageEvent;
|
use crate::MessageEvent;
|
||||||
|
|
||||||
@ -34,14 +34,15 @@ impl FeedbackEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A type of feedback.
|
/// A type of feedback.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum FeedbackType {
|
pub enum FeedbackType {
|
||||||
/// Sent when a message is received.
|
/// Sent when a message is received.
|
||||||
Delivered,
|
Delivered,
|
||||||
|
|
||||||
/// Sent when a message has been observed by the end user.
|
/// Sent when a message has been observed by the end user.
|
||||||
Read,
|
Read,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
//! Types for the *m.room_key_request* event.
|
//! Types for the *m.room_key_request* event.
|
||||||
|
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_events_macros::BasicEventContent;
|
use ruma_events_macros::BasicEventContent;
|
||||||
use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId};
|
use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
use crate::BasicEvent;
|
use crate::BasicEvent;
|
||||||
|
|
||||||
@ -35,18 +35,18 @@ pub struct RoomKeyRequestEventContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A new key request or a cancellation of a previous request.
|
/// A new key request or a cancellation of a previous request.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
/// Request a key.
|
/// Request a key.
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// Cancel a request for a key.
|
/// Cancel a request for a key.
|
||||||
#[serde(rename = "request_cancellation")]
|
#[ruma_enum(rename = "request_cancellation")]
|
||||||
#[strum(serialize = "request_cancellation")]
|
|
||||||
CancelRequest,
|
CancelRequest,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about a requested key.
|
/// Information about a requested key.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//! [GET /_matrix/federation/v1/query/profile](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-query-profile)
|
//! [GET /_matrix/federation/v1/query/profile](https://matrix.org/docs/spec/server_server/r0.1.4#get-matrix-federation-v1-query-profile)
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
use ruma_common::StringEnum;
|
||||||
use ruma_identifiers::UserId;
|
use ruma_identifiers::UserId;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -22,7 +22,7 @@ ruma_api! {
|
|||||||
/// Profile field to query.
|
/// Profile field to query.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub field: Option<ProfileField>,
|
pub field: Option<&'a ProfileField>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -52,13 +52,16 @@ impl Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Profile fields to specify in query.
|
/// Profile fields to specify in query.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
|
||||||
pub enum ProfileField {
|
pub enum ProfileField {
|
||||||
/// Display name of the user.
|
/// Display name of the user.
|
||||||
#[serde(rename = "displayname")]
|
#[ruma_enum(rename = "displayname")]
|
||||||
DisplayName,
|
DisplayName,
|
||||||
|
|
||||||
/// Avatar URL for the user's avatar.
|
/// Avatar URL for the user's avatar.
|
||||||
#[serde(rename = "avatar_url")]
|
#[ruma_enum(rename = "avatar_url")]
|
||||||
AvatarUrl,
|
AvatarUrl,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ ruma-identifiers-validation = { version = "0.1.1", path = "../ruma-identifiers-v
|
|||||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||||
# Renamed so we can have a serde feature.
|
# Renamed so we can have a serde feature.
|
||||||
serde1 = { package = "serde", version = "1.0.114", optional = true, features = ["derive"] }
|
serde1 = { package = "serde", version = "1.0.114", optional = true, features = ["derive"] }
|
||||||
strum = { version = "0.19.2", features = ["derive"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
matches = "0.1.8"
|
matches = "0.1.8"
|
||||||
|
@ -19,7 +19,6 @@ ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
|||||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||||
serde = { version = "1.0.114", features = ["derive"] }
|
serde = { version = "1.0.114", features = ["derive"] }
|
||||||
serde_json = "1.0.57"
|
serde_json = "1.0.57"
|
||||||
strum = { version = "0.19.2", features = ["derive"] }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable-exhaustive-types = []
|
unstable-exhaustive-types = []
|
||||||
|
@ -4,14 +4,13 @@ use js_int::UInt;
|
|||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
push::{PusherData, Tweak},
|
push::{PusherData, Tweak},
|
||||||
Outgoing,
|
Outgoing, StringEnum,
|
||||||
};
|
};
|
||||||
use ruma_events::EventType;
|
use ruma_events::EventType;
|
||||||
use ruma_identifiers::{EventId, RoomAliasId, RoomId, UserId};
|
use ruma_identifiers::{EventId, RoomAliasId, RoomId, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::value::RawValue as RawJsonValue;
|
use serde_json::value::RawValue as RawJsonValue;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use strum::{Display, EnumString};
|
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -137,16 +136,17 @@ impl<'a> Notification<'a> {
|
|||||||
///
|
///
|
||||||
/// This may be used by push gateways to deliver less time-sensitive
|
/// This may be used by push gateways to deliver less time-sensitive
|
||||||
/// notifications in a way that will preserve battery power on mobile devices.
|
/// notifications in a way that will preserve battery power on mobile devices.
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, StringEnum)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
#[strum(serialize_all = "snake_case")]
|
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub enum NotificationPriority {
|
pub enum NotificationPriority {
|
||||||
/// A high priority notification
|
/// A high priority notification
|
||||||
High,
|
High,
|
||||||
|
|
||||||
/// A low priority notification
|
/// A low priority notification
|
||||||
Low,
|
Low,
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
_Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for NotificationPriority {
|
impl Default for NotificationPriority {
|
||||||
|
@ -15,6 +15,7 @@ version = "0.6.0-dev.1"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.12.3"
|
base64 = "0.12.3"
|
||||||
ring = "0.16.15"
|
ring = "0.16.15"
|
||||||
|
ruma-common = { version = "0.2.0", path = "../ruma-common" }
|
||||||
ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
ruma-identifiers = { version = "0.17.4", path = "../ruma-identifiers" }
|
||||||
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
ruma-serde = { version = "0.2.3", path = "../ruma-serde" }
|
||||||
serde_json = "1.0.57"
|
serde_json = "1.0.57"
|
||||||
|
@ -49,6 +49,8 @@ use std::{
|
|||||||
fmt::{Display, Formatter, Result as FmtResult},
|
fmt::{Display, Formatter, Result as FmtResult},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use ruma_common::{AsRefStr, DisplayAsRefStr};
|
||||||
|
|
||||||
pub use functions::{
|
pub use functions::{
|
||||||
canonical_json, content_hash, hash_and_sign_event, redact, reference_hash, sign_json,
|
canonical_json, content_hash, hash_and_sign_event, redact, reference_hash, sign_json,
|
||||||
verify_event, verify_json,
|
verify_event, verify_json,
|
||||||
@ -114,22 +116,13 @@ impl From<ruma_serde::CanonicalJsonError> for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The algorithm used for signing data.
|
/// The algorithm used for signing data.
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, AsRefStr, DisplayAsRefStr)]
|
||||||
|
#[ruma_enum(rename_all = "snake_case")]
|
||||||
pub enum Algorithm {
|
pub enum Algorithm {
|
||||||
/// The Ed25519 digital signature algorithm.
|
/// The Ed25519 digital signature algorithm.
|
||||||
Ed25519,
|
Ed25519,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Algorithm {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
|
||||||
let name = match *self {
|
|
||||||
Self::Ed25519 => "ed25519",
|
|
||||||
};
|
|
||||||
|
|
||||||
write!(f, "{}", name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An error when trying to extract the algorithm and version from a key identifier.
|
/// An error when trying to extract the algorithm and version from a key identifier.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
enum SplitError<'a> {
|
enum SplitError<'a> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user