Derive Clone for basically everything. Close #3."

This commit is contained in:
Jimmy Cuadra 2016-10-16 16:20:21 -07:00
parent e6c0dd4bdc
commit f57a1aec48
27 changed files with 54 additions and 53 deletions

View File

@ -8,7 +8,7 @@ room_event! {
}
/// The payload of an `AnswerEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AnswerEventContent {
/// The VoIP session description.
pub answer: SessionDescription,

View File

@ -8,7 +8,7 @@ room_event! {
}
/// The payload of a `CandidatesEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CandidatesEventContent {
/// The ID of the call this event relates to.
pub call_id: String,
@ -19,7 +19,7 @@ pub struct CandidatesEventContent {
}
/// An ICE (Interactive Connectivity Establishment) candidate.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Candidate {
/// The SDP "a" line of the candidate.
pub candidate: String,

View File

@ -7,7 +7,7 @@ room_event! {
}
/// The payload of a `HangupEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct HangupEventContent {
/// The ID of the call this event relates to.
pub call_id: String,

View File

@ -8,7 +8,7 @@ room_event! {
}
/// The payload of an `InviteEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct InviteEventContent {
/// A unique identifer for the call.
pub call_id: String,

View File

@ -8,7 +8,7 @@ pub mod hangup;
pub mod invite;
/// A VoIP session description.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SessionDescription {
/// The type of session description.
pub session_type: SessionDescriptionType,
@ -17,7 +17,7 @@ pub struct SessionDescription {
}
/// The type of VoIP session description.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum SessionDescriptionType {
/// An answer.
#[serde(rename="answer")]

View File

@ -27,6 +27,7 @@ pub mod tag;
pub mod typing;
/// An error when attempting to convert a string to an enum that only accepts certain values.
#[derive(Clone, Copy, Debug)]
pub struct ParseError;
/// The type of an event.

View File

@ -33,7 +33,7 @@ macro_rules! event {
}
) => {
$(#[$attr])*
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct $name {
/// The event's content.
pub content: $content_type,
@ -78,7 +78,7 @@ macro_rules! room_event {
}
) => {
$(#[$attr])*
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct $name {
/// The event's content.
pub content: $content_type,
@ -146,7 +146,7 @@ macro_rules! state_event {
) => {
$(#[$attr])*
#[allow(missing_docs)]
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct $name {
/// The event's content.
pub content: $content_type,

View File

@ -11,7 +11,7 @@ event! {
}
/// The payload of a `PresenceEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PresenceEventContent {
/// The current avatar URL for this user.
#[serde(skip_serializing_if="Option::is_none")]
@ -36,7 +36,7 @@ pub struct PresenceEventContent {
}
/// A description of a user's connectivity and availability for chat.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum PresenceState {
/// Disconnected from the service.
#[serde(rename="offline")]

View File

@ -19,7 +19,7 @@ event! {
pub type ReceiptEventContent = HashMap<EventId, Receipts>;
/// A collection of receipts.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Receipts {
/// A collection of users who have sent *m.read* receipts for this event.
pub m_read: UserReceipts,
@ -31,7 +31,7 @@ pub struct Receipts {
pub type UserReceipts = HashMap<UserId, Receipt>;
/// An acknowledgement of an event.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Receipt {
/// The timestamp the receipt was sent at.
pub ts: u64,

View File

@ -8,7 +8,7 @@ state_event! {
}
/// The payload of an `AliasesEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AliasesEventContent {
/// A list of room aliases.
pub aliases: Vec<RoomAliasId>,

View File

@ -10,7 +10,7 @@ state_event! {
}
/// The payload of an `AvatarEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AvatarEventContent {
/// Information about the avatar image.
pub info: ImageInfo,

View File

@ -8,7 +8,7 @@ state_event! {
}
/// The payload of a `CanonicalAliasEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CanonicalAliasEventContent {
/// The canonical alias.
pub alias: RoomAliasId,

View File

@ -9,7 +9,7 @@ state_event! {
}
/// The payload of a `CreateEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateEventContent {
/// The `user_id` of the room creator. This is set by the homeserver.
pub creator: UserId,

View File

@ -9,14 +9,14 @@ state_event! {
}
/// The payload of a `GuestAccessEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct GuestAccessEventContent {
/// A policy for guest user access to a room.
pub guest_access: GuestAccess,
}
/// A policy for guest user access to a room.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum GuestAccess {
/// Guests are allowed to join the room.
#[serde(rename="can_join")]

View File

@ -7,14 +7,14 @@ state_event! {
}
/// The payload of a `HistoryVisibilityEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct HistoryVisibilityEventContent {
/// Who can see the room history.
pub history_visibility: HistoryVisibility,
}
/// Who can see a room's history.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum HistoryVisibility {
/// 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

View File

@ -6,14 +6,14 @@ state_event! {
}
/// The payload of a `JoinRulesEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct JoinRulesEventContent {
/// 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.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum JoinRule {
/// A user who wishes to join the room must first receive an invite to the room from someone
/// already inside of the room.

View File

@ -27,7 +27,7 @@ state_event! {
}
/// The payload of a `MemberEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct MemberEventContent {
/// The avatar URL for this user.
#[serde(skip_serializing_if="Option::is_none")]
@ -47,7 +47,7 @@ pub struct MemberEventContent {
}
/// The membership state of a user.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum MembershipState {
/// The user is banned.
#[serde(rename="ban")]
@ -81,7 +81,7 @@ impl_enum! {
}
/// Information about a third party invitation.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThirdPartyInvite {
/// A name which can be displayed to represent the user instead of their third party
/// identifier.
@ -93,7 +93,7 @@ pub struct ThirdPartyInvite {
/// A block of content which has been signed, which servers can use to verify a third party
/// invitation.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SignedContent {
/// The invited Matrix user ID.
///

View File

@ -11,7 +11,7 @@ room_event! {
}
/// The message type of message event, e.g. `m.image` or `m.text`.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum MessageType {
/// An audio message.
#[serde(rename="m.audio")]
@ -47,7 +47,7 @@ pub enum MessageType {
}
/// The payload of a message event.
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub enum MessageEventContent {
/// An audio message.
Audio(AudioMessageEventContent),
@ -75,7 +75,7 @@ pub enum MessageEventContent {
}
/// The payload of an audio message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct AudioMessageEventContent {
/// The textual representation of this message.
pub body: String,
@ -89,7 +89,7 @@ pub struct AudioMessageEventContent {
}
/// Metadata about an audio clip.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct AudioInfo {
/// The duration of the audio in milliseconds.
#[serde(skip_serializing_if="Option::is_none")]
@ -103,7 +103,7 @@ pub struct AudioInfo {
}
/// The payload of an emote message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct EmoteMessageEventContent {
/// The emote action to perform.
pub body: String,
@ -112,7 +112,7 @@ pub struct EmoteMessageEventContent {
}
/// The payload of a file message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct FileMessageEventContent {
/// A human-readable description of the file. This is recommended to be the filename of the
/// original upload.
@ -133,7 +133,7 @@ pub struct FileMessageEventContent {
}
/// Metadata about a file.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct FileInfo {
/// The mimetype of the file, e.g. "application/msword."
pub mimetype: String,
@ -142,7 +142,7 @@ pub struct FileInfo {
}
/// The payload of an image message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ImageMessageEventContent {
/// A textual representation of the image. This could be the alt text of the image, the filename
/// of the image, or some kind of content description for accessibility e.g. "image attachment."
@ -163,7 +163,7 @@ pub struct ImageMessageEventContent {
}
/// The payload of a location message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct LocationMessageEventContent {
/// A description of the location e.g. "Big Ben, London, UK,"or some kind of content description
/// for accessibility, e.g. "location attachment."
@ -181,7 +181,7 @@ pub struct LocationMessageEventContent {
}
/// The payload of a notice message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct NoticeMessageEventContent {
/// The notice text to send.
pub body: String,
@ -190,7 +190,7 @@ pub struct NoticeMessageEventContent {
}
/// The payload of a text message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct TextMessageEventContent {
/// The body of the message.
pub body: String,
@ -199,7 +199,7 @@ pub struct TextMessageEventContent {
}
/// The payload of a video message.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct VideoMessageEventContent {
/// A description of the video, e.g. "Gangnam Style," or some kind of content description for
/// accessibility, e.g. "video attachment."
@ -214,7 +214,7 @@ pub struct VideoMessageEventContent {
}
/// Metadata about a video.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct VideoInfo {
/// The duration of the video in milliseconds.
#[serde(skip_serializing_if="Option::is_none")]

View File

@ -18,7 +18,7 @@ pub mod third_party_invite;
pub mod topic;
/// Metadata about an image.
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ImageInfo {
/// The height of the image in pixels.
pub height: u64,

View File

@ -6,7 +6,7 @@ state_event! {
}
/// The payload of a `NameEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct NameEventContent {
/// The name of the room. This MUST NOT exceed 255 bytes.
pub name: String,

View File

@ -12,7 +12,7 @@ state_event! {
}
/// The payload of a `PowerLevelsEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PowerLevelsEventContent {
/// The level required to ban a user.
pub ban: u64,

View File

@ -11,7 +11,7 @@ room_event! {
}
/// The payload of a `RedactionEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RedactionEventContent {
/// The reason for the redaction, if any.
#[serde(skip_serializing_if="Option::is_none")]

View File

@ -10,7 +10,7 @@ state_event! {
}
/// The payload of a `ThirdPartyInviteEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThirdPartyInviteEventContent {
/// A user-readable string which represents the user who has been invited.
pub display_name: String,
@ -27,7 +27,7 @@ pub struct ThirdPartyInviteEventContent {
}
/// A public key for signing a third party invite token.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PublicKey {
/// An optional URL which can be fetched to validate whether the key has been revoked.
///

View File

@ -6,7 +6,7 @@ state_event! {
}
/// The payload of a `TopicEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TopicEventContent {
/// The topic text.
pub topic: String,

View File

@ -9,7 +9,7 @@ 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)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum StrippedState {
/// A stripped-down version of the *m.room.avatar* event.
RoomAvatar(StrippedRoomAvatar),
@ -25,7 +25,7 @@ pub enum StrippedState {
}
/// The general form of a `StrippedState`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct StrippedStateContent<C> where C: Deserialize + Serialize {
/// Data specific to the event type.
pub content: C,

View File

@ -8,14 +8,14 @@ event! {
}
/// The payload of a `TagEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TagEventContent {
/// A map of tag names to tag info.
pub tags: HashMap<String, TagInfo>,
}
/// Information about a tag.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TagInfo {
/// Value to use for lexicographically ordering rooms with this tag.
#[serde(skip_serializing_if="Option::is_none")]

View File

@ -11,7 +11,7 @@ event! {
}
/// The payload of a `TypingEvent`.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TypingEventContent {
/// The list of user IDs typing in this room, if any.
pub user_ids: Vec<EventId>,