Add second generic parameter to events and add missing docs.
This commit is contained in:
parent
8288c82b28
commit
070a6fe633
@ -4,7 +4,7 @@ use RoomEvent;
|
|||||||
use super::SessionDescription;
|
use super::SessionDescription;
|
||||||
|
|
||||||
/// This event is sent by the callee when they wish to answer the call.
|
/// This event is sent by the callee when they wish to answer the call.
|
||||||
pub type AnswerEvent = RoomEvent<AnswerEventContent>;
|
pub type AnswerEvent = RoomEvent<AnswerEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of an `AnswerEvent`.
|
/// The payload of an `AnswerEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -4,7 +4,7 @@ use RoomEvent;
|
|||||||
|
|
||||||
/// This event is sent by callers after sending an invite and by the callee after answering.
|
/// This event is sent by callers after sending an invite and by the callee after answering.
|
||||||
/// Its purpose is to give the other party additional ICE candidates to try using to communicate.
|
/// Its purpose is to give the other party additional ICE candidates to try using to communicate.
|
||||||
pub type CandidatesEvent = RoomEvent<CandidatesEventContent>;
|
pub type CandidatesEvent = RoomEvent<CandidatesEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `CandidatesEvent`.
|
/// The payload of a `CandidatesEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -4,7 +4,7 @@ use RoomEvent;
|
|||||||
|
|
||||||
/// Sent by either party to signal their termination of the call. This can be sent either once the
|
/// Sent by either party to signal their termination of the call. This can be sent either once the
|
||||||
/// call has has been established or before to abort the call.
|
/// call has has been established or before to abort the call.
|
||||||
pub type HangupEvent = RoomEvent<HangupEventContent>;
|
pub type HangupEvent = RoomEvent<HangupEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `HangupEvent`.
|
/// The payload of a `HangupEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -4,7 +4,7 @@ use RoomEvent;
|
|||||||
use super::SessionDescription;
|
use super::SessionDescription;
|
||||||
|
|
||||||
/// This event is sent by the caller when they wish to establish a call.
|
/// This event is sent by the caller when they wish to establish a call.
|
||||||
pub type InviteEvent = RoomEvent<InviteEventContent>;
|
pub type InviteEvent = RoomEvent<InviteEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of an `InviteEvent`.
|
/// The payload of an `InviteEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
78
src/lib.rs
78
src/lib.rs
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#![feature(custom_derive, plugin)]
|
#![feature(custom_derive, plugin)]
|
||||||
#![plugin(serde_macros)]
|
#![plugin(serde_macros)]
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
@ -20,16 +21,6 @@ pub mod stripped;
|
|||||||
pub mod tag;
|
pub mod tag;
|
||||||
pub mod typing;
|
pub mod typing;
|
||||||
|
|
||||||
/// A basic event.
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
pub struct Event<T> where T: Deserialize + Serialize {
|
|
||||||
pub content: T,
|
|
||||||
#[serde(rename="type")]
|
|
||||||
pub event_type: EventType,
|
|
||||||
/// Extra key-value pairs to be mixed into the top-level JSON representation of the event.
|
|
||||||
pub extra_content: Option<Value>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The type of an event.
|
/// The type of an event.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub enum EventType {
|
pub enum EventType {
|
||||||
@ -81,34 +72,79 @@ pub enum EventType {
|
|||||||
Custom(String),
|
Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An event within the context of a room.
|
/// A basic event.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct RoomEvent<T> where T: Deserialize + Serialize {
|
pub struct Event<C, E> where C: Deserialize + Serialize, E: Deserialize + Serialize {
|
||||||
pub content: T,
|
/// Data specific to the event type.
|
||||||
pub event_id: String,
|
pub content: C,
|
||||||
/// Extra key-value pairs to be mixed into the top-level JSON representation of the event.
|
|
||||||
pub extra_content: Option<Value>,
|
/// The type of the event.
|
||||||
#[serde(rename="type")]
|
#[serde(rename="type")]
|
||||||
pub event_type: EventType,
|
pub event_type: EventType,
|
||||||
|
|
||||||
|
/// Extra top-level key-value pairs specific to this event type, but that are not under the
|
||||||
|
/// `content` field.
|
||||||
|
pub extra_content: E,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An event within the context of a room.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct RoomEvent<C, E> where C: Deserialize + Serialize, E: Deserialize + Serialize {
|
||||||
|
/// Data specific to the event type.
|
||||||
|
pub content: C,
|
||||||
|
|
||||||
|
/// The unique identifier for the event.
|
||||||
|
pub event_id: String,
|
||||||
|
|
||||||
|
/// Extra top-level key-value pairs specific to this event type, but that are not under the
|
||||||
|
/// `content` field.
|
||||||
|
pub extra_content: E,
|
||||||
|
|
||||||
|
/// The type of the event.
|
||||||
|
#[serde(rename="type")]
|
||||||
|
pub event_type: EventType,
|
||||||
|
|
||||||
|
/// The unique identifier for the room associated with this event.
|
||||||
pub room_id: String,
|
pub room_id: String,
|
||||||
|
|
||||||
|
/// Additional key-value pairs not signed by the homeserver.
|
||||||
pub unsigned: Option<Value>,
|
pub unsigned: Option<Value>,
|
||||||
|
|
||||||
|
/// The unique identifier for the user associated with this event.
|
||||||
#[serde(rename="sender")]
|
#[serde(rename="sender")]
|
||||||
pub user_id: String,
|
pub user_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An event that describes persistent state about a room.
|
/// An event that describes persistent state about a room.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct StateEvent<T> where T: Deserialize + Serialize {
|
pub struct StateEvent<C, E> where C: Deserialize + Serialize, E: Deserialize + Serialize {
|
||||||
pub content: T,
|
/// Data specific to the event type.
|
||||||
|
pub content: C,
|
||||||
|
|
||||||
|
/// The unique identifier for the event.
|
||||||
pub event_id: String,
|
pub event_id: String,
|
||||||
|
|
||||||
|
/// The type of the event.
|
||||||
#[serde(rename="type")]
|
#[serde(rename="type")]
|
||||||
pub event_type: EventType,
|
pub event_type: EventType,
|
||||||
/// Extra key-value pairs to be mixed into the top-level JSON representation of the event.
|
|
||||||
pub extra_content: Option<Value>,
|
/// Extra top-level key-value pairs specific to this event type, but that are not under the
|
||||||
pub prev_content: Option<T>,
|
/// `content` field.
|
||||||
|
pub extra_content: E,
|
||||||
|
|
||||||
|
/// The previous content for this state key, if any.
|
||||||
|
pub prev_content: Option<C>,
|
||||||
|
|
||||||
|
/// The unique identifier for the room associated with this event.
|
||||||
pub room_id: String,
|
pub room_id: String,
|
||||||
|
|
||||||
|
/// A key that determines which piece of room state the event represents.
|
||||||
pub state_key: String,
|
pub state_key: String,
|
||||||
|
|
||||||
|
/// Additional key-value pairs not signed by the homeserver.
|
||||||
pub unsigned: Option<Value>,
|
pub unsigned: Option<Value>,
|
||||||
|
|
||||||
|
/// The unique identifier for the user associated with this event.
|
||||||
#[serde(rename="sender")]
|
#[serde(rename="sender")]
|
||||||
pub user_id: String,
|
pub user_id: String,
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,30 @@
|
|||||||
//! Types for the *m.presence* event.
|
//! Types for the *m.presence* event.
|
||||||
|
|
||||||
use EventType;
|
use Event;
|
||||||
|
|
||||||
/// Informs the client of a user's presence state change.
|
/// Informs the client of a user's presence state change.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
pub type PresenceEvent = Event<PresenceEventContent, PresenceEventExtraContent>;
|
||||||
pub struct PresenceEvent {
|
|
||||||
pub content: PresenceEventContent,
|
|
||||||
pub event_id: String,
|
|
||||||
#[serde(rename="type")]
|
|
||||||
pub event_type: EventType,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The payload of a `PresenceEvent`.
|
/// The payload of a `PresenceEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct PresenceEventContent {
|
pub struct PresenceEventContent {
|
||||||
/// The current avatar URL for this user.
|
/// The current avatar URL for this user.
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
|
|
||||||
|
/// Whether or not the user is currently active.
|
||||||
|
pub currently_active: bool,
|
||||||
|
|
||||||
/// The current display name for this user.
|
/// The current display name for this user.
|
||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
|
|
||||||
/// The last time since this used performed some action, in milliseconds.
|
/// The last time since this used performed some action, in milliseconds.
|
||||||
pub last_active_ago: Option<u64>,
|
pub last_active_ago: Option<u64>,
|
||||||
|
|
||||||
/// The presence state for this user.
|
/// The presence state for this user.
|
||||||
pub presence: PresenceState,
|
pub presence: PresenceState,
|
||||||
|
|
||||||
|
/// The unique identifier for the user associated with this event.
|
||||||
|
pub user_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A description of a user's connectivity and availability for chat.
|
/// A description of a user's connectivity and availability for chat.
|
||||||
@ -29,12 +32,23 @@ pub struct PresenceEventContent {
|
|||||||
pub enum PresenceState {
|
pub enum PresenceState {
|
||||||
/// Connected to the service and available for chat.
|
/// Connected to the service and available for chat.
|
||||||
FreeForChat,
|
FreeForChat,
|
||||||
|
|
||||||
/// Connected to the service but not visible to other users.
|
/// Connected to the service but not visible to other users.
|
||||||
Hidden,
|
Hidden,
|
||||||
|
|
||||||
/// Disconnected from the service.
|
/// Disconnected from the service.
|
||||||
Offline,
|
Offline,
|
||||||
|
|
||||||
/// Connected to the service.
|
/// Connected to the service.
|
||||||
Online,
|
Online,
|
||||||
|
|
||||||
/// Connected to the service but not available for chat.
|
/// Connected to the service but not available for chat.
|
||||||
Unavailable,
|
Unavailable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra content for a `PresenceEvent`.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct PresenceEventExtraContent {
|
||||||
|
/// The unique identifier for the event.
|
||||||
|
pub event_id: String,
|
||||||
|
}
|
||||||
|
@ -2,16 +2,10 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use EventType;
|
use Event;
|
||||||
|
|
||||||
/// Informs the client of new receipts.
|
/// Informs the client of new receipts.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
pub type ReceiptEvent = Event<ReceiptEventContent, ReceiptEventExtraContent>;
|
||||||
pub struct ReceiptEvent {
|
|
||||||
pub content: ReceiptEventContent,
|
|
||||||
#[serde(rename="type")]
|
|
||||||
pub event_type: EventType,
|
|
||||||
pub room_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The payload of a `ReceiptEvent`.
|
/// The payload of a `ReceiptEvent`.
|
||||||
///
|
///
|
||||||
@ -37,3 +31,10 @@ pub struct Receipt {
|
|||||||
/// The timestamp the receipt was sent at.
|
/// The timestamp the receipt was sent at.
|
||||||
pub ts: u64,
|
pub ts: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra content for a `PresenceEvent`.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct ReceiptEventExtraContent {
|
||||||
|
/// The unique identifier for the room associated with this event.
|
||||||
|
pub room_id: String,
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use StateEvent;
|
use StateEvent;
|
||||||
|
|
||||||
/// Informs the room about what room aliases it has been given.
|
/// Informs the room about what room aliases it has been given.
|
||||||
pub type AliasesEvent = StateEvent<AliasesEventContent>;
|
pub type AliasesEvent = StateEvent<AliasesEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of an `AliasesEvent`.
|
/// The payload of an `AliasesEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -6,13 +6,17 @@ use super::ImageInfo;
|
|||||||
/// A picture that is associated with the room.
|
/// A picture that is associated with the room.
|
||||||
///
|
///
|
||||||
/// This can be displayed alongside the room information.
|
/// This can be displayed alongside the room information.
|
||||||
pub type AvatarEvent = StateEvent<AvatarEventContent>;
|
pub type AvatarEvent = StateEvent<AvatarEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of an `AvatarEvent`.
|
/// The payload of an `AvatarEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct AvatarEventContent {
|
pub struct AvatarEventContent {
|
||||||
|
/// Information about the avatar image.
|
||||||
pub info: ImageInfo,
|
pub info: ImageInfo,
|
||||||
|
/// Information about the avatar thumbnail image.
|
||||||
pub thumbnail_info: ImageInfo,
|
pub thumbnail_info: ImageInfo,
|
||||||
|
/// URL of the avatar thumbnail image.
|
||||||
pub thumbnail_url: String,
|
pub thumbnail_url: String,
|
||||||
|
/// URL of the avatar image.
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use StateEvent;
|
use StateEvent;
|
||||||
|
|
||||||
/// Informs the room as to which alias is the canonical one.
|
/// Informs the room as to which alias is the canonical one.
|
||||||
pub type CanonicalAliasEvent = StateEvent<CanonicalAliasEventContent>;
|
pub type CanonicalAliasEvent = StateEvent<CanonicalAliasEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `CanonicalAliasEvent`.
|
/// The payload of a `CanonicalAliasEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -4,7 +4,7 @@ use StateEvent;
|
|||||||
|
|
||||||
/// This is the first event in a room and cannot be changed. It acts as the root of all other
|
/// This is the first event in a room and cannot be changed. It acts as the root of all other
|
||||||
/// events.
|
/// events.
|
||||||
pub type CreateEvent = StateEvent<CreateEventContent>;
|
pub type CreateEvent = StateEvent<CreateEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `CreateEvent`.
|
/// The payload of a `CreateEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -6,11 +6,12 @@ use StateEvent;
|
|||||||
///
|
///
|
||||||
/// 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`.
|
||||||
pub type GuestAccessEvent = StateEvent<GuestAccessEventContent>;
|
pub type GuestAccessEvent = StateEvent<GuestAccessEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `GuestAccessEvent`.
|
/// The payload of a `GuestAccessEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct GuestAccessEventContent {
|
pub struct GuestAccessEventContent {
|
||||||
|
/// A policy for guest user access to a room.
|
||||||
pub guest_access: GuestAccess,
|
pub guest_access: GuestAccess,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use StateEvent;
|
|||||||
|
|
||||||
/// This event controls whether a member of a room can see the events that happened in a room from
|
/// This event controls whether a member of a room can see the events that happened in a room from
|
||||||
/// before they joined.
|
/// before they joined.
|
||||||
pub type HistoryVisibilityEvent = StateEvent<HistoryVisibilityEventContent>;
|
pub type HistoryVisibilityEvent = StateEvent<HistoryVisibilityEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `HistoryVisibilityEvent`.
|
/// The payload of a `HistoryVisibilityEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use StateEvent;
|
use StateEvent;
|
||||||
|
|
||||||
/// Describes how users are allowed to join the room.
|
/// Describes how users are allowed to join the room.
|
||||||
pub type JoinRulesEvent = StateEvent<JoinRulesEventContent>;
|
pub type JoinRulesEvent = StateEvent<JoinRulesEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `JoinRulesEvent`.
|
/// The payload of a `JoinRulesEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Types for the *m.room.member* event.
|
//! Types for the *m.room.member* event.
|
||||||
|
|
||||||
use EventType;
|
use StateEvent;
|
||||||
use stripped::StrippedState;
|
use stripped::StrippedState;
|
||||||
|
|
||||||
/// The current membership state of a user in the room.
|
/// The current membership state of a user in the room.
|
||||||
@ -16,26 +16,20 @@ use stripped::StrippedState;
|
|||||||
/// This event may also include an *invite_room_state* key outside the *content* key. If present,
|
/// This event may also include an *invite_room_state* key outside the *content* key. If present,
|
||||||
/// this contains an array of `StrippedState` events. These events provide information on a few
|
/// this contains an array of `StrippedState` events. These events provide information on a few
|
||||||
/// select state events such as the room name.
|
/// select state events such as the room name.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
pub type MemberEvent = StateEvent<MemberEventContent, MemberEventExtraContent>;
|
||||||
pub struct MemberEvent {
|
|
||||||
pub content: MemberEventContent,
|
|
||||||
pub event_id: String,
|
|
||||||
#[serde(rename="type")]
|
|
||||||
pub event_type: EventType,
|
|
||||||
pub invite_room_state: Option<Vec<StrippedState>>,
|
|
||||||
pub prev_content: Option<MemberEventContent>,
|
|
||||||
pub room_id: String,
|
|
||||||
pub state_key: String,
|
|
||||||
#[serde(rename="sender")]
|
|
||||||
pub user_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The payload of a `MemberEvent`.
|
/// The payload of a `MemberEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct MemberEventContent {
|
pub struct MemberEventContent {
|
||||||
|
/// The avatar URL for this user.
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
|
|
||||||
|
/// The display name for this user.
|
||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
|
|
||||||
|
/// The membership state of this user.
|
||||||
pub membership: MembershipState,
|
pub membership: MembershipState,
|
||||||
|
|
||||||
/// Warning: This field is not implemented yet and its type will change!
|
/// Warning: This field is not implemented yet and its type will change!
|
||||||
pub third_party_invite: (), // TODO
|
pub third_party_invite: (), // TODO
|
||||||
}
|
}
|
||||||
@ -43,9 +37,25 @@ pub struct MemberEventContent {
|
|||||||
/// The membership state of a user.
|
/// The membership state of a user.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub enum MembershipState {
|
pub enum MembershipState {
|
||||||
|
/// The user is banned.
|
||||||
Ban,
|
Ban,
|
||||||
|
|
||||||
|
/// The user has been invited.
|
||||||
Invite,
|
Invite,
|
||||||
|
|
||||||
|
/// The user has joined.
|
||||||
Join,
|
Join,
|
||||||
|
|
||||||
|
/// The user has requested to join.
|
||||||
Knock,
|
Knock,
|
||||||
|
|
||||||
|
/// The user has left.
|
||||||
Leave,
|
Leave,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra content for a `MemberEvent`.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct MemberEventExtraContent {
|
||||||
|
/// A subset of the state of the room at the time of the invite.
|
||||||
|
pub invite_room_state: Option<Vec<StrippedState>>,
|
||||||
|
}
|
||||||
|
@ -4,31 +4,61 @@ use RoomEvent;
|
|||||||
use super::ImageInfo;
|
use super::ImageInfo;
|
||||||
|
|
||||||
/// A message sent to a room.
|
/// A message sent to a room.
|
||||||
pub type MessageEvent = RoomEvent<MessageEventContent>;
|
pub type MessageEvent = RoomEvent<MessageEventContent, ()>;
|
||||||
|
|
||||||
/// The message type of message event, e.g. `m.image` or `m.text`.
|
/// The message type of message event, e.g. `m.image` or `m.text`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub enum MessageType {
|
pub enum MessageType {
|
||||||
|
/// An audio message.
|
||||||
Audio,
|
Audio,
|
||||||
|
|
||||||
|
/// An emote message.
|
||||||
Emote,
|
Emote,
|
||||||
|
|
||||||
|
/// A file message.
|
||||||
File,
|
File,
|
||||||
|
|
||||||
|
/// An image message.
|
||||||
Image,
|
Image,
|
||||||
|
|
||||||
|
/// A location message.
|
||||||
Location,
|
Location,
|
||||||
|
|
||||||
|
/// A notice message.
|
||||||
Notice,
|
Notice,
|
||||||
|
|
||||||
|
/// A text message.
|
||||||
Text,
|
Text,
|
||||||
|
|
||||||
|
/// A video message.
|
||||||
Video,
|
Video,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The payload of a message event.
|
/// The payload of a message event.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub enum MessageEventContent {
|
pub enum MessageEventContent {
|
||||||
|
/// An audio message.
|
||||||
Audio(AudioMessageEventContent),
|
Audio(AudioMessageEventContent),
|
||||||
|
|
||||||
|
/// An emote message.
|
||||||
Emote(EmoteMessageEventContent),
|
Emote(EmoteMessageEventContent),
|
||||||
|
|
||||||
|
/// An file message.
|
||||||
File(FileMessageEventContent),
|
File(FileMessageEventContent),
|
||||||
|
|
||||||
|
/// An image message.
|
||||||
Image(ImageMessageEventContent),
|
Image(ImageMessageEventContent),
|
||||||
|
|
||||||
|
/// An location message.
|
||||||
Location(LocationMessageEventContent),
|
Location(LocationMessageEventContent),
|
||||||
|
|
||||||
|
/// An notice message.
|
||||||
Notice(NoticeMessageEventContent),
|
Notice(NoticeMessageEventContent),
|
||||||
|
|
||||||
|
/// An text message.
|
||||||
Text(TextMessageEventContent),
|
Text(TextMessageEventContent),
|
||||||
|
|
||||||
|
/// An video message.
|
||||||
Video(VideoMessageEventContent),
|
Video(VideoMessageEventContent),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,12 @@ pub mod topic;
|
|||||||
/// Metadata about an image.
|
/// Metadata about an image.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct ImageInfo {
|
pub struct ImageInfo {
|
||||||
|
/// The height of the image in pixels.
|
||||||
pub height: u64,
|
pub height: u64,
|
||||||
|
/// The MIME type of the image, e.g. "image/png."
|
||||||
pub mimetype: String,
|
pub mimetype: String,
|
||||||
|
/// The file size of the image in bytes.
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
|
/// The width of the image in pixels.
|
||||||
pub width: u64,
|
pub width: u64,
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use StateEvent;
|
use StateEvent;
|
||||||
|
|
||||||
/// A human-friendly room name designed to be displayed to the end-user.
|
/// A human-friendly room name designed to be displayed to the end-user.
|
||||||
pub type NameEvent = StateEvent<NameEventContent>;
|
pub type NameEvent = StateEvent<NameEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `NameEvent`.
|
/// The payload of a `NameEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -5,17 +5,39 @@ use std::collections::HashMap;
|
|||||||
use StateEvent;
|
use StateEvent;
|
||||||
|
|
||||||
/// Defines the power levels (privileges) of users in the room.
|
/// Defines the power levels (privileges) of users in the room.
|
||||||
pub type PowerLevelsEvent = StateEvent<PowerLevelsEventContent>;
|
pub type PowerLevelsEvent = StateEvent<PowerLevelsEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `PowerLevelsEvent`.
|
/// The payload of a `PowerLevelsEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct PowerLevelsEventContent {
|
pub struct PowerLevelsEventContent {
|
||||||
|
/// The level required to ban a user.
|
||||||
pub ban: u64,
|
pub ban: u64,
|
||||||
|
|
||||||
|
/// The level required to send specific event types.
|
||||||
|
///
|
||||||
|
/// This is a mapping from event type to power level required.
|
||||||
pub events: HashMap<String, u64>,
|
pub events: HashMap<String, u64>,
|
||||||
|
|
||||||
|
/// The default level required to send message events.
|
||||||
pub events_default: u64,
|
pub events_default: u64,
|
||||||
|
|
||||||
|
/// The level required to invite a user.
|
||||||
|
pub invite: u64,
|
||||||
|
|
||||||
|
/// The level required to kick a user.
|
||||||
pub kick: u64,
|
pub kick: u64,
|
||||||
|
|
||||||
|
/// The level required to redact an event.
|
||||||
pub redact: u64,
|
pub redact: u64,
|
||||||
|
|
||||||
|
/// The default level required to send state events.
|
||||||
pub state_default: u64,
|
pub state_default: u64,
|
||||||
|
|
||||||
|
/// The power levels for specific users.
|
||||||
|
///
|
||||||
|
/// This is a mapping from `user_id` to power level for that user.
|
||||||
pub users: HashMap<String, u64>,
|
pub users: HashMap<String, u64>,
|
||||||
|
|
||||||
|
/// The default power level for every user in the room.
|
||||||
pub users_default: u64,
|
pub users_default: u64,
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,9 @@
|
|||||||
//! Types for the *m.room.redaction* event.
|
//! Types for the *m.room.redaction* event.
|
||||||
|
|
||||||
use EventType;
|
use RoomEvent;
|
||||||
|
|
||||||
/// A redaction of an event.
|
/// A redaction of an event.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
pub type RedactionEvent = RoomEvent<RedactionEventContent, RedactionEventExtraContent>;
|
||||||
pub struct RedactionEvent {
|
|
||||||
pub content: RedactionEventContent,
|
|
||||||
pub event_id: String,
|
|
||||||
#[serde(rename="type")]
|
|
||||||
pub event_type: EventType,
|
|
||||||
/// The ID of the event that was redacted.
|
|
||||||
pub redacts: String,
|
|
||||||
pub room_id: String,
|
|
||||||
#[serde(rename="sender")]
|
|
||||||
pub user_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The payload of a `RedactionEvent`.
|
/// The payload of a `RedactionEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -22,3 +11,10 @@ pub struct RedactionEventContent {
|
|||||||
/// The reason for the redaction, if any.
|
/// The reason for the redaction, if any.
|
||||||
pub reason: Option<String>,
|
pub reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra content for a `RedactionEvent`.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct RedactionEventExtraContent {
|
||||||
|
/// The ID of the event that was redacted.
|
||||||
|
pub redacts: String,
|
||||||
|
}
|
||||||
|
@ -7,12 +7,33 @@ use StateEvent;
|
|||||||
/// Acts as an *m.room.member* invite event, where there isn't a target user_id to invite. This
|
/// Acts as an *m.room.member* invite event, where there isn't a target user_id to invite. This
|
||||||
/// event contains a token and a public key whose private key must be used to sign the token. Any
|
/// event contains a token and a public key whose private key must be used to sign the token. Any
|
||||||
/// user who can present that signature may use this invitation to join the target room.
|
/// user who can present that signature may use this invitation to join the target room.
|
||||||
pub type ThirdPartyInviteEvent = StateEvent<ThirdPartyInviteEventContent>;
|
pub type ThirdPartyInviteEvent = StateEvent<ThirdPartyInviteEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `ThirdPartyInviteEvent`.
|
/// The payload of a `ThirdPartyInviteEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct ThirdPartyInviteEventContent {
|
pub struct ThirdPartyInviteEventContent {
|
||||||
|
/// A user-readable string which represents the user who has been invited.
|
||||||
pub display_name: String,
|
pub display_name: String,
|
||||||
|
|
||||||
|
/// A URL which can be fetched to validate whether the key has been revoked.
|
||||||
pub key_validity_url: String,
|
pub key_validity_url: String,
|
||||||
|
|
||||||
|
/// A Base64-encoded Ed25519 key with which the token must be signed.
|
||||||
|
pub public_key: String,
|
||||||
|
|
||||||
|
/// Keys with which the token may be signed.
|
||||||
|
pub public_keys: Option<Vec<PublicKey>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A public key for signing a third party invite token.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct PublicKey {
|
||||||
|
/// An optional URL which can be fetched to validate whether the key has been revoked.
|
||||||
|
///
|
||||||
|
/// The URL must return a JSON object containing a boolean property named 'valid'.
|
||||||
|
/// If this URL is absent, the key must be considered valid indefinitely.
|
||||||
|
pub key_validity_url: Option<String>,
|
||||||
|
|
||||||
|
/// A Base64-encoded Ed25519 key with which the token must be signed.
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use StateEvent;
|
use StateEvent;
|
||||||
|
|
||||||
/// A topic is a short message detailing what is currently being discussed in the room.
|
/// A topic is a short message detailing what is currently being discussed in the room.
|
||||||
pub type TopicEvent = StateEvent<TopicEventContent>;
|
pub type TopicEvent = StateEvent<TopicEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `TopicEvent`.
|
/// The payload of a `TopicEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@ -11,22 +11,39 @@ use room::name::NameEventContent;
|
|||||||
/// A stripped-down version of a state event that is included along with some other events.
|
/// A stripped-down version of a state event that is included along with some other events.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub enum StrippedState {
|
pub enum StrippedState {
|
||||||
|
/// A stripped-down version of the *m.room.avatar* event.
|
||||||
RoomAvatar(StrippedRoomAvatar),
|
RoomAvatar(StrippedRoomAvatar),
|
||||||
|
|
||||||
|
/// A stripped-down version of the *m.room.canonical_alias* event.
|
||||||
RoomCanonicalAlias(StrippedRoomCanonicalAlias),
|
RoomCanonicalAlias(StrippedRoomCanonicalAlias),
|
||||||
|
|
||||||
|
/// A stripped-down version of the *m.room.join_rules* event.
|
||||||
RoomJoinRules(StrippedRoomJoinRules),
|
RoomJoinRules(StrippedRoomJoinRules),
|
||||||
|
|
||||||
|
/// A stripped-down version of the *m.room.name* event.
|
||||||
RoomName(StrippedRoomName),
|
RoomName(StrippedRoomName),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The general form of a `StrippedState`.
|
/// The general form of a `StrippedState`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct StrippedStateContent<T> where T: Deserialize + Serialize {
|
pub struct StrippedStateContent<C> where C: Deserialize + Serialize {
|
||||||
pub content: T,
|
/// Data specific to the event type.
|
||||||
|
pub content: C,
|
||||||
|
/// The type of the event.
|
||||||
#[serde(rename="type")]
|
#[serde(rename="type")]
|
||||||
pub event_type: EventType,
|
pub event_type: EventType,
|
||||||
|
/// A key that determines which piece of room state the event represents.
|
||||||
pub state_key: String,
|
pub state_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A stripped-down version of the *m.room.avatar* event.
|
||||||
pub type StrippedRoomAvatar = StrippedStateContent<AvatarEventContent>;
|
pub type StrippedRoomAvatar = StrippedStateContent<AvatarEventContent>;
|
||||||
|
|
||||||
|
/// A stripped-down version of the *m.room.canonical_alias* event.
|
||||||
pub type StrippedRoomCanonicalAlias = StrippedStateContent<CanonicalAliasEventContent>;
|
pub type StrippedRoomCanonicalAlias = StrippedStateContent<CanonicalAliasEventContent>;
|
||||||
|
|
||||||
|
/// A stripped-down version of the *m.room.join_rules* event.
|
||||||
pub type StrippedRoomJoinRules = StrippedStateContent<JoinRulesEventContent>;
|
pub type StrippedRoomJoinRules = StrippedStateContent<JoinRulesEventContent>;
|
||||||
|
|
||||||
|
/// A stripped-down version of the *m.room.name* event.
|
||||||
pub type StrippedRoomName = StrippedStateContent<NameEventContent>;
|
pub type StrippedRoomName = StrippedStateContent<NameEventContent>;
|
||||||
|
@ -5,7 +5,7 @@ use std::collections::HashMap;
|
|||||||
use Event;
|
use Event;
|
||||||
|
|
||||||
/// Informs the client of tags on a room.
|
/// Informs the client of tags on a room.
|
||||||
pub type TagEvent = Event<TagEventContent>;
|
pub type TagEvent = Event<TagEventContent, ()>;
|
||||||
|
|
||||||
/// The payload of a `TagEvent`.
|
/// The payload of a `TagEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -17,5 +17,6 @@ pub struct TagEventContent {
|
|||||||
/// Information about a tag.
|
/// Information about a tag.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct TagInfo {
|
pub struct TagInfo {
|
||||||
|
/// Value to use for lexicographically ordering rooms with this tag.
|
||||||
pub order: Option<u64>,
|
pub order: Option<u64>,
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
//! Types for the *m.typing* event.
|
//! Types for the *m.typing* event.
|
||||||
|
|
||||||
use EventType;
|
use Event;
|
||||||
|
|
||||||
/// Informs the client of the list of users currently typing.
|
/// Informs the client of the list of users currently typing.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
pub type TypingEvent = Event<TypingEventContent, TypingEventExtraContent>;
|
||||||
pub struct TypingEvent {
|
|
||||||
/// The payload.
|
|
||||||
pub content: TypingEventContent,
|
|
||||||
#[serde(rename="type")]
|
|
||||||
pub event_type: EventType,
|
|
||||||
/// The ID of the room associated with this event.
|
|
||||||
pub room_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The payload of a `TypingEvent`.
|
/// The payload of a `TypingEvent`.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
@ -19,3 +11,10 @@ pub struct TypingEventContent {
|
|||||||
/// The list of user IDs typing in this room, if any.
|
/// The list of user IDs typing in this room, if any.
|
||||||
pub user_ids: Vec<String>,
|
pub user_ids: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra content for a `TypingEvent`.
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct TypingEventExtraContent {
|
||||||
|
/// The unique identifier for the room associated with this event.
|
||||||
|
pub room_id: String,
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user