Commit 0d7526b8 authored by Jordan Petridis's avatar Jordan Petridis 🌱

Merge branch 'derive' into 'master'

backend: use derive to implement Clone

See merge request World/fractal!228
parents e23713b9 3c3dc3b8
use std::collections::HashMap;
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Member {
// The mxid is either inside the json object, or outside of it.
// Since we don't know, we always have to populate it manually
......@@ -12,16 +12,6 @@ pub struct Member {
pub avatar: Option<String>,
}
impl Clone for Member {
fn clone(&self) -> Member {
Member {
alias: self.alias.clone(),
uid: self.uid.clone(),
avatar: self.avatar.clone(),
}
}
}
impl Member {
pub fn get_alias(&self) -> String {
match self.alias {
......
......@@ -8,8 +8,7 @@ use std::collections::HashMap;
use self::serde_json::Value as JsonValue;
use self::time::Duration;
#[derive(Debug)]
#[derive(Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
pub sender: String,
pub mtype: String,
......@@ -28,27 +27,6 @@ pub struct Message {
pub in_reply_to: Option<String>,
}
impl Clone for Message {
fn clone(&self) -> Message {
Message {
sender: self.sender.clone(),
mtype: self.mtype.clone(),
body: self.body.clone(),
date: self.date.clone(),
room: self.room.clone(),
thumb: self.thumb.clone(),
url: self.url.clone(),
id: self.id.clone(),
formatted_body: self.formatted_body.clone(),
format: self.format.clone(),
source: self.source.clone(),
receipt: self.receipt.clone(),
redacted: self.redacted,
in_reply_to: self.in_reply_to.clone(),
}
}
}
impl Default for Message {
fn default() -> Message {
Message {
......
......@@ -7,7 +7,7 @@ use model::message::Message;
use model::member::MemberList;
use model::member::Member;
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Room {
pub id: String,
pub avatar: Option<String>,
......@@ -91,31 +91,6 @@ impl Room {
}
}
impl Clone for Room {
fn clone(&self) -> Room {
Room {
id: self.id.clone(),
name: self.name.clone(),
avatar: self.avatar.clone(),
topic: self.topic.clone(),
alias: self.alias.clone(),
guest_can_join: self.guest_can_join,
world_readable: self.world_readable,
n_members: self.n_members,
notifications: self.notifications,
highlight: self.highlight,
messages: self.messages.iter().cloned().collect(),
members: self.members.clone(),
fav: self.fav,
left: self.left,
inv: self.inv,
direct: self.direct,
inv_sender: self.inv_sender.clone(),
power_levels: self.power_levels.clone(),
}
}
}
impl PartialEq for Room {
fn eq(&self, other: &Room) -> bool {
self.id == other.id
......
extern crate serde_json;
use self::serde_json::Value as JsonValue;
#[derive(Debug)]
#[derive(Clone)]
#[derive(Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Sticker {
pub name: String,
pub description: String,
......@@ -14,9 +11,7 @@ pub struct Sticker {
pub size: (i32, i32),
}
#[derive(Debug)]
#[derive(Clone)]
#[derive(Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StickerGroup {
pub name: String,
pub asset: String,
......
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserInfo {
pub added_at: u64,
pub medium: String,
pub validated_at: u64,
pub address: String,
}
impl Clone for UserInfo {
fn clone(&self) -> UserInfo {
UserInfo {
added_at: self.added_at.clone(),
medium: self.medium.clone(),
validated_at: self.validated_at.clone(),
address: self.address.clone(),
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment