Revert the package name to ruma-events.
This commit is contained in:
parent
f662f086b3
commit
68265a9387
@ -1,13 +1,13 @@
|
||||
[package]
|
||||
authors = ["Jimmy Cuadra <jimmy@jimmycuadra.com>"]
|
||||
description = "Types shared by ruma and ruma-client."
|
||||
documentation = "http://ruma.github.io/ruma-common/ruma_common"
|
||||
description = "Serializable types for the events in the Matrix specification."
|
||||
documentation = "http://ruma.github.io/ruma-common/ruma_events"
|
||||
homepage = "https://github.com/ruma/ruma-events"
|
||||
keywords = ["matrix", "matrix.org", "chat", "messaging", "ruma"]
|
||||
license = "MIT"
|
||||
name = "ruma-common"
|
||||
name = "ruma-events"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/ruma/ruma-common"
|
||||
repository = "https://github.com/ruma/ruma-events"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
|
@ -1,6 +1,6 @@
|
||||
# ruma-common
|
||||
# ruma-events
|
||||
|
||||
**ruma-common** contains serializable types for the events and APIs in the [Matrix](https://matrix.org/) client-server specification that can be shared by client and server code.
|
||||
**ruma-events** contains serializable types for the events in the [Matrix](https://matrix.org/) specification that can be shared by client and server code.
|
||||
|
||||
## Status
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.call.answer* event.
|
||||
|
||||
use events::RoomEvent;
|
||||
use RoomEvent;
|
||||
use super::SessionDescription;
|
||||
|
||||
/// This event is sent by the callee when they wish to answer the call.
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.call.candidates* event.
|
||||
|
||||
use events::RoomEvent;
|
||||
use RoomEvent;
|
||||
|
||||
/// 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.
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.call.hangup* event.
|
||||
|
||||
use events::RoomEvent;
|
||||
use RoomEvent;
|
||||
|
||||
/// 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.
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.call.invite* event.
|
||||
|
||||
use events::RoomEvent;
|
||||
use RoomEvent;
|
||||
use super::SessionDescription;
|
||||
|
||||
/// This event is sent by the caller when they wish to establish a call.
|
@ -1,105 +0,0 @@
|
||||
//! Event types.
|
||||
|
||||
use std::fmt::{Display, Formatter, Error as FmtError};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod call;
|
||||
pub mod presence;
|
||||
pub mod receipt;
|
||||
pub mod room;
|
||||
pub mod stripped;
|
||||
pub mod tag;
|
||||
pub mod typing;
|
||||
|
||||
/// The type of an event.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub enum EventType {
|
||||
CallAnswer,
|
||||
CallCandidates,
|
||||
CallHangup,
|
||||
CallInvite,
|
||||
Presence,
|
||||
Receipt,
|
||||
RoomAliases,
|
||||
RoomAvatar,
|
||||
RoomCanonicalAlias,
|
||||
RoomCreate,
|
||||
RoomGuestAccess,
|
||||
RoomHistoryVisibility,
|
||||
RoomJoinRules,
|
||||
RoomMember,
|
||||
RoomMessage,
|
||||
RoomName,
|
||||
RoomPowerLevels,
|
||||
RoomRedaction,
|
||||
RoomThirdPartyInvite,
|
||||
RoomTopic,
|
||||
Tag,
|
||||
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,
|
||||
}
|
||||
|
||||
/// An event within the context of a room.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct RoomEvent<T> where T: Deserialize + Serialize {
|
||||
pub content: T,
|
||||
pub event_id: String,
|
||||
#[serde(rename="type")]
|
||||
pub event_type: EventType,
|
||||
pub room_id: String,
|
||||
#[serde(rename="sender")]
|
||||
pub user_id: String,
|
||||
}
|
||||
|
||||
/// An event that describes persistent state about a room.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct StateEvent<T> where T: Deserialize + Serialize {
|
||||
pub content: T,
|
||||
pub event_id: String,
|
||||
#[serde(rename="type")]
|
||||
pub event_type: EventType,
|
||||
pub prev_content: Option<T>,
|
||||
pub room_id: String,
|
||||
pub state_key: String,
|
||||
#[serde(rename="sender")]
|
||||
pub user_id: String,
|
||||
}
|
||||
|
||||
impl Display for EventType {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
|
||||
let event_type_str = match *self {
|
||||
EventType::CallAnswer => "m.call.answer",
|
||||
EventType::CallCandidates => "m.call.candidates",
|
||||
EventType::CallHangup => "m.call.hangup",
|
||||
EventType::CallInvite => "m.call.invite",
|
||||
EventType::Presence => "m.presence",
|
||||
EventType::Receipt => "m.receipt",
|
||||
EventType::RoomAliases => "m.room.aliases",
|
||||
EventType::RoomAvatar => "m.room.avatar",
|
||||
EventType::RoomCanonicalAlias => "m.room.canonical_alias",
|
||||
EventType::RoomCreate => "m.room.create",
|
||||
EventType::RoomGuestAccess => "m.room.guest_access",
|
||||
EventType::RoomHistoryVisibility => "m.room.history_visibility",
|
||||
EventType::RoomJoinRules => "m.room.join_rules",
|
||||
EventType::RoomMember => "m.room.member",
|
||||
EventType::RoomMessage => "m.room.message",
|
||||
EventType::RoomName => "m.room.name",
|
||||
EventType::RoomPowerLevels => "m.room.power_levels",
|
||||
EventType::RoomRedaction => "m.room.redaction",
|
||||
EventType::RoomThirdPartyInvite => "m.room.third_party_invite",
|
||||
EventType::RoomTopic => "m.room.topic",
|
||||
EventType::Tag => "m.tag",
|
||||
EventType::Typing => "m.typing",
|
||||
};
|
||||
|
||||
write!(f, "{}", event_type_str)
|
||||
}
|
||||
}
|
109
src/lib.rs
109
src/lib.rs
@ -1,10 +1,111 @@
|
||||
//! Crate ruma_common contains serializable types for the events and APIs in the
|
||||
//! [Matrix](https://matrix.org) client-server specification that can be shared by client and
|
||||
//! server code.
|
||||
//! Crate ruma_events contains serializable types for the events in the [Matrix](https://matrix.org)
|
||||
//! specification that can be shared by client and server code.
|
||||
|
||||
#![feature(custom_derive, plugin)]
|
||||
#![plugin(serde_macros)]
|
||||
|
||||
extern crate serde;
|
||||
|
||||
pub mod events;
|
||||
use std::fmt::{Display, Formatter, Error as FmtError};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod call;
|
||||
pub mod presence;
|
||||
pub mod receipt;
|
||||
pub mod room;
|
||||
pub mod stripped;
|
||||
pub mod tag;
|
||||
pub mod typing;
|
||||
|
||||
/// The type of an event.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub enum EventType {
|
||||
CallAnswer,
|
||||
CallCandidates,
|
||||
CallHangup,
|
||||
CallInvite,
|
||||
Presence,
|
||||
Receipt,
|
||||
RoomAliases,
|
||||
RoomAvatar,
|
||||
RoomCanonicalAlias,
|
||||
RoomCreate,
|
||||
RoomGuestAccess,
|
||||
RoomHistoryVisibility,
|
||||
RoomJoinRules,
|
||||
RoomMember,
|
||||
RoomMessage,
|
||||
RoomName,
|
||||
RoomPowerLevels,
|
||||
RoomRedaction,
|
||||
RoomThirdPartyInvite,
|
||||
RoomTopic,
|
||||
Tag,
|
||||
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,
|
||||
}
|
||||
|
||||
/// An event within the context of a room.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct RoomEvent<T> where T: Deserialize + Serialize {
|
||||
pub content: T,
|
||||
pub event_id: String,
|
||||
#[serde(rename="type")]
|
||||
pub event_type: EventType,
|
||||
pub room_id: String,
|
||||
#[serde(rename="sender")]
|
||||
pub user_id: String,
|
||||
}
|
||||
|
||||
/// An event that describes persistent state about a room.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct StateEvent<T> where T: Deserialize + Serialize {
|
||||
pub content: T,
|
||||
pub event_id: String,
|
||||
#[serde(rename="type")]
|
||||
pub event_type: EventType,
|
||||
pub prev_content: Option<T>,
|
||||
pub room_id: String,
|
||||
pub state_key: String,
|
||||
#[serde(rename="sender")]
|
||||
pub user_id: String,
|
||||
}
|
||||
|
||||
impl Display for EventType {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
|
||||
let event_type_str = match *self {
|
||||
EventType::CallAnswer => "m.call.answer",
|
||||
EventType::CallCandidates => "m.call.candidates",
|
||||
EventType::CallHangup => "m.call.hangup",
|
||||
EventType::CallInvite => "m.call.invite",
|
||||
EventType::Presence => "m.presence",
|
||||
EventType::Receipt => "m.receipt",
|
||||
EventType::RoomAliases => "m.room.aliases",
|
||||
EventType::RoomAvatar => "m.room.avatar",
|
||||
EventType::RoomCanonicalAlias => "m.room.canonical_alias",
|
||||
EventType::RoomCreate => "m.room.create",
|
||||
EventType::RoomGuestAccess => "m.room.guest_access",
|
||||
EventType::RoomHistoryVisibility => "m.room.history_visibility",
|
||||
EventType::RoomJoinRules => "m.room.join_rules",
|
||||
EventType::RoomMember => "m.room.member",
|
||||
EventType::RoomMessage => "m.room.message",
|
||||
EventType::RoomName => "m.room.name",
|
||||
EventType::RoomPowerLevels => "m.room.power_levels",
|
||||
EventType::RoomRedaction => "m.room.redaction",
|
||||
EventType::RoomThirdPartyInvite => "m.room.third_party_invite",
|
||||
EventType::RoomTopic => "m.room.topic",
|
||||
EventType::Tag => "m.tag",
|
||||
EventType::Typing => "m.typing",
|
||||
};
|
||||
|
||||
write!(f, "{}", event_type_str)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.presence* event.
|
||||
|
||||
use events::EventType;
|
||||
use EventType;
|
||||
|
||||
/// Informs the client of a user's presence state change.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use events::EventType;
|
||||
use EventType;
|
||||
|
||||
/// Informs the client of new receipts.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.aliases* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// Informs the room about what room aliases it has been given.
|
||||
pub type AliasesEvent = StateEvent<AliasesEventContent>;
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.avatar* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
use super::ImageInfo;
|
||||
|
||||
/// A picture that is associated with the room.
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.canonical_alias* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// Informs the room as to which alias is the canonical one.
|
||||
pub type CanonicalAliasEvent = StateEvent<CanonicalAliasEventContent>;
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.create* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// This is the first event in a room and cannot be changed. It acts as the root of all other
|
||||
/// events.
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.guest_access* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// Controls whether guest users are allowed to join rooms.
|
||||
///
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.history_visibility* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// This event controls whether a member of a room can see the events that happened in a room from
|
||||
/// before they joined.
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.join_rules* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// Describes how users are allowed to join the room.
|
||||
pub type JoinRulesEvent = StateEvent<JoinRulesEventContent>;
|
@ -1,7 +1,7 @@
|
||||
//! Types for the *m.room.member* event.
|
||||
|
||||
use events::EventType;
|
||||
use events::stripped::StrippedState;
|
||||
use EventType;
|
||||
use stripped::StrippedState;
|
||||
|
||||
/// The current membership state of a user in the room.
|
||||
///
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.message* event.
|
||||
|
||||
use events::RoomEvent;
|
||||
use RoomEvent;
|
||||
use super::ImageInfo;
|
||||
|
||||
/// A message sent to a room.
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.name* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// A human-friendly room name designed to be displayed to the end-user.
|
||||
pub type NameEvent = StateEvent<NameEventContent>;
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// Defines the power levels (privileges) of users in the room.
|
||||
pub type PowerLevelsEvent = StateEvent<PowerLevelsEventContent>;
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.redaction* event.
|
||||
|
||||
use events::EventType;
|
||||
use EventType;
|
||||
|
||||
/// A redaction of an event.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.third_party_invite* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// An invitation to a room issued to a third party identifier, rather than a matrix user ID.
|
||||
///
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.room.topic* event.
|
||||
|
||||
use events::StateEvent;
|
||||
use StateEvent;
|
||||
|
||||
/// A topic is a short message detailing what is currently being discussed in the room.
|
||||
pub type TopicEvent = StateEvent<TopicEventContent>;
|
@ -2,11 +2,11 @@
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use events::EventType;
|
||||
use events::room::avatar::AvatarEventContent;
|
||||
use events::room::canonical_alias::CanonicalAliasEventContent;
|
||||
use events::room::join_rules::JoinRulesEventContent;
|
||||
use events::room::name::NameEventContent;
|
||||
use EventType;
|
||||
use room::avatar::AvatarEventContent;
|
||||
use room::canonical_alias::CanonicalAliasEventContent;
|
||||
use room::join_rules::JoinRulesEventContent;
|
||||
use room::name::NameEventContent;
|
||||
|
||||
/// A stripped-down version of a state event that is included along with some other events.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use events::Event;
|
||||
use Event;
|
||||
|
||||
/// Informs the client of tags on a room.
|
||||
pub type TagEvent = Event<TagEventContent>;
|
@ -1,6 +1,6 @@
|
||||
//! Types for the *m.typing* event.
|
||||
|
||||
use events::EventType;
|
||||
use EventType;
|
||||
|
||||
/// Informs the client of the list of users currently typing.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
Loading…
x
Reference in New Issue
Block a user