Declare more state event content structs without ruma_event!
This commit is contained in:
		
							parent
							
								
									eceef3b96d
								
							
						
					
					
						commit
						1377487b6c
					
				| @ -1,30 +1,27 @@ | |||||||
| //! Types for the *m.room.encryption* event.
 | //! Types for the *m.room.encryption* event.
 | ||||||
| 
 | 
 | ||||||
| use js_int::UInt; | use js_int::UInt; | ||||||
| use ruma_events_macros::ruma_event; | use ruma_events_macros::{FromRaw, StateEventContent}; | ||||||
|  | use serde::Serialize; | ||||||
| 
 | 
 | ||||||
| use crate::Algorithm; | use crate::Algorithm; | ||||||
| 
 | 
 | ||||||
| ruma_event! { | /// Defines how messages sent in this room should be encrypted.
 | ||||||
|     /// Defines how messages sent in this room should be encrypted.
 | #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)] | ||||||
|     EncryptionEvent { | #[ruma_event(type = "m.room.encryption")] | ||||||
|         kind: StateEvent, | pub struct EncryptionEventContent { | ||||||
|         event_type: "m.room.encryption", |     /// The encryption algorithm to be used to encrypt messages sent in this room.
 | ||||||
|         content: { |     ///
 | ||||||
|             /// The encryption algorithm to be used to encrypt messages sent in this room.
 |     /// Must be `m.megolm.v1.aes-sha2`.
 | ||||||
|             ///
 |     pub algorithm: Algorithm, | ||||||
|             /// Must be `m.megolm.v1.aes-sha2`.
 |  | ||||||
|             pub algorithm: Algorithm, |  | ||||||
| 
 | 
 | ||||||
|             /// How long the session should be used before changing it.
 |     /// How long the session should be used before changing it.
 | ||||||
|             ///
 |     ///
 | ||||||
|             /// 604800000 (a week) is the recommended default.
 |     /// 604800000 (a week) is the recommended default.
 | ||||||
|             pub rotation_period_ms: Option<UInt>, |     pub rotation_period_ms: Option<UInt>, | ||||||
| 
 | 
 | ||||||
|             /// How many messages should be sent before changing the session.
 |     /// How many messages should be sent before changing the session.
 | ||||||
|             ///
 |     ///
 | ||||||
|             /// 100 is the recommended default.
 |     /// 100 is the recommended default.
 | ||||||
|             pub rotation_period_msgs: Option<UInt>, |     pub rotation_period_msgs: Option<UInt>, | ||||||
|         }, |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,22 +1,18 @@ | |||||||
| //! Types for the *m.room.guest_access* event.
 | //! Types for the *m.room.guest_access* event.
 | ||||||
| 
 | 
 | ||||||
| use ruma_events_macros::ruma_event; | use ruma_events_macros::{FromRaw, StateEventContent}; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| use strum::{Display, EnumString}; | use strum::{Display, EnumString}; | ||||||
| 
 | 
 | ||||||
| ruma_event! { | /// Controls whether guest users are allowed to join rooms.
 | ||||||
|     /// Controls whether guest users are allowed to join rooms.
 | ///
 | ||||||
|     ///
 | /// This event controls whether guest users are allowed to join rooms. If this event is absent,
 | ||||||
|     /// This event controls whether guest users are allowed to join rooms. If this event is absent,
 | /// servers should act as if it is present and has the value `GuestAccess::Forbidden`.
 | ||||||
|     /// servers should act as if it is present and has the value `GuestAccess::Forbidden`.
 | #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)] | ||||||
|     GuestAccessEvent { | #[ruma_event(type = "m.room.guest_access")] | ||||||
|         kind: StateEvent, | pub struct GuestAccessEventContent { | ||||||
|         event_type: "m.room.guest_access", |     /// A policy for guest user access to a room.
 | ||||||
|         content: { |     pub guest_access: GuestAccess, | ||||||
|             /// A policy for guest user access to a room.
 |  | ||||||
|             pub guest_access: GuestAccess, |  | ||||||
|         }, |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// A policy for guest user access to a room.
 | /// A policy for guest user access to a room.
 | ||||||
|  | |||||||
| @ -1,20 +1,16 @@ | |||||||
| //! Types for the *m.room.history_visibility* event.
 | //! Types for the *m.room.history_visibility* event.
 | ||||||
| 
 | 
 | ||||||
| use ruma_events_macros::ruma_event; | use ruma_events_macros::{FromRaw, StateEventContent}; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| use strum::{Display, EnumString}; | use strum::{Display, EnumString}; | ||||||
| 
 | 
 | ||||||
| ruma_event! { | /// This event controls whether a member of a room can see the events that happened in a room
 | ||||||
|     /// This event controls whether a member of a room can see the events that happened in a room
 | /// from before they joined.
 | ||||||
|     /// from before they joined.
 | #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)] | ||||||
|     HistoryVisibilityEvent { | #[ruma_event(type = "m.room.history_visibility")] | ||||||
|         kind: StateEvent, | pub struct HistoryVisibilityEventContent { | ||||||
|         event_type: "m.room.history_visibility", |     /// Who can see the room history.
 | ||||||
|         content: { |     pub history_visibility: HistoryVisibility, | ||||||
|             /// Who can see the room history.
 |  | ||||||
|             pub history_visibility: HistoryVisibility, |  | ||||||
|         }, |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// Who can see a room's history.
 | /// Who can see a room's history.
 | ||||||
|  | |||||||
| @ -1,19 +1,15 @@ | |||||||
| //! Types for the *m.room.join_rules* event.
 | //! Types for the *m.room.join_rules* event.
 | ||||||
| 
 | 
 | ||||||
| use ruma_events_macros::ruma_event; | use ruma_events_macros::{FromRaw, StateEventContent}; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| use strum::{Display, EnumString}; | use strum::{Display, EnumString}; | ||||||
| 
 | 
 | ||||||
| ruma_event! { | /// Describes how users are allowed to join the room.
 | ||||||
|     /// Describes how users are allowed to join the room.
 | #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)] | ||||||
|     JoinRulesEvent { | #[ruma_event(type = "m.room.join_rules")] | ||||||
|         kind: StateEvent, | pub struct JoinRulesEventContent { | ||||||
|         event_type: "m.room.join_rules", |     /// The type of rules used for users wishing to join this room.
 | ||||||
|         content: { |     pub join_rule: JoinRule, | ||||||
|             /// The type of rules used for users wishing to join this room.
 |  | ||||||
|             pub join_rule: JoinRule, |  | ||||||
|         }, |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// The rule used for users wishing to join this room.
 | /// The rule used for users wishing to join this room.
 | ||||||
|  | |||||||
| @ -2,63 +2,59 @@ | |||||||
| 
 | 
 | ||||||
| use std::collections::BTreeMap; | use std::collections::BTreeMap; | ||||||
| 
 | 
 | ||||||
| use ruma_events_macros::ruma_event; | use ruma_events_macros::{FromRaw, StateEventContent}; | ||||||
| use ruma_identifiers::UserId; | use ruma_identifiers::UserId; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| use strum::{Display, EnumString}; | use strum::{Display, EnumString}; | ||||||
| 
 | 
 | ||||||
| ruma_event! { | /// The current membership state of a user in the room.
 | ||||||
|     /// The current membership state of a user in the room.
 | ///
 | ||||||
|     ///
 | /// Adjusts the membership state for a user in a room. It is preferable to use the membership
 | ||||||
|     /// Adjusts the membership state for a user in a room. It is preferable to use the membership
 | /// APIs (`/rooms/<room id>/invite` etc) when performing membership actions rather than
 | ||||||
|     /// APIs (`/rooms/<room id>/invite` etc) when performing membership actions rather than
 | /// adjusting the state directly as there are a restricted set of valid transformations. For
 | ||||||
|     /// adjusting the state directly as there are a restricted set of valid transformations. For
 | /// example, user A cannot force user B to join a room, and trying to force this state change
 | ||||||
|     /// example, user A cannot force user B to join a room, and trying to force this state change
 | /// directly will fail.
 | ||||||
|     /// directly will fail.
 | ///
 | ||||||
|     ///
 | /// The `third_party_invite` property will be set if this invite is an *invite* event and is the
 | ||||||
|     /// The `third_party_invite` property will be set if this invite is an *invite* event and is the
 | /// successor of an *m.room.third_party_invite* event, and absent otherwise.
 | ||||||
|     /// successor of an *m.room.third_party_invite* event, and absent otherwise.
 | ///
 | ||||||
|     ///
 | /// This event may also include an `invite_room_state` key inside the event's unsigned data. If
 | ||||||
|     /// This event may also include an `invite_room_state` key inside the event's unsigned data. If
 | /// present, this contains an array of `StrippedState` events. These events provide information
 | ||||||
|     /// present, this contains an array of `StrippedState` events. These events provide information
 | /// on a subset of state events such as the room name. Note that ruma-events treats unsigned
 | ||||||
|     /// on a subset of state events such as the room name. Note that ruma-events treats unsigned
 | /// data on events as arbitrary JSON values, and the ruma-events types for this event don't
 | ||||||
|     /// data on events as arbitrary JSON values, and the ruma-events types for this event don't
 | /// provide direct access to `invite_room_state`. If you need this data, you must extract and
 | ||||||
|     /// provide direct access to `invite_room_state`. If you need this data, you must extract and
 | /// convert it from a `serde_json::Value` yourself.
 | ||||||
|     /// convert it from a `serde_json::Value` yourself.
 | ///
 | ||||||
|     ///
 | /// The user for which a membership applies is represented by the `state_key`. Under some
 | ||||||
|     /// The user for which a membership applies is represented by the `state_key`. Under some
 | /// conditions, the `sender` and `state_key` may not match - this may be interpreted as the
 | ||||||
|     /// conditions, the `sender` and `state_key` may not match - this may be interpreted as the
 | /// `sender` affecting the membership state of the `state_key` user.
 | ||||||
|     /// `sender` affecting the membership state of the `state_key` user.
 | ///
 | ||||||
|     ///
 | /// The membership for a given user can change over time. Previous membership can be retrieved
 | ||||||
|     /// The membership for a given user can change over time. Previous membership can be retrieved
 | /// from the `prev_content` object on an event. If not present, the user's previous membership
 | ||||||
|     /// from the `prev_content` object on an event. If not present, the user's previous membership
 | /// must be assumed as leave.
 | ||||||
|     /// must be assumed as leave.
 | #[derive(Clone, Debug, Serialize, FromRaw, StateEventContent)] | ||||||
|     MemberEvent { | #[ruma_event(type = "m.room.member")] | ||||||
|         kind: StateEvent, | pub struct MemberEventContent { | ||||||
|         event_type: "m.room.member", |     /// The avatar URL for this user, if any. This is added by the homeserver.
 | ||||||
|         content: { |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|             /// The avatar URL for this user, if any. This is added by the homeserver.
 |     pub avatar_url: Option<String>, | ||||||
|             #[serde(skip_serializing_if = "Option::is_none")] |  | ||||||
|             pub avatar_url: Option<String>, |  | ||||||
| 
 | 
 | ||||||
|             /// The display name for this user, if any. This is added by the homeserver.
 |     /// The display name for this user, if any. This is added by the homeserver.
 | ||||||
|             #[serde(skip_serializing_if = "Option::is_none")] |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|             pub displayname: Option<String>, |     pub displayname: Option<String>, | ||||||
| 
 | 
 | ||||||
|             /// Flag indicating if the room containing this event was created
 |     /// Flag indicating if the room containing this event was created
 | ||||||
|             /// with the intention of being a direct chat.
 |     /// with the intention of being a direct chat.
 | ||||||
|             #[serde(skip_serializing_if = "Option::is_none")] |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|             pub is_direct: Option<bool>, |     pub is_direct: Option<bool>, | ||||||
| 
 | 
 | ||||||
|             /// The membership state of this user.
 |     /// The membership state of this user.
 | ||||||
|             pub membership: MembershipState, |     pub membership: MembershipState, | ||||||
| 
 | 
 | ||||||
|             /// If this member event is the successor to a third party invitation, this field will
 |     /// If this member event is the successor to a third party invitation, this field will
 | ||||||
|             /// contain information about that invitation.
 |     /// contain information about that invitation.
 | ||||||
|             #[serde(skip_serializing_if = "Option::is_none")] |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|             pub third_party_invite: Option<ThirdPartyInvite>, |     pub third_party_invite: Option<ThirdPartyInvite>, | ||||||
|         }, |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// The membership state of a user.
 | /// The membership state of a user.
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user