Merge branch 'refs/heads/feature/reformatting' into develop
This commit is contained in:
commit
5a50d49df8
17 changed files with 62 additions and 88 deletions
|
|
@ -1,15 +1,13 @@
|
|||
use std::os::unix::net::UnixStream;
|
||||
use std::env::var;
|
||||
use std::error::Error;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::PathBuf;
|
||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||
use log::debug;
|
||||
use serde_json::{json, Value};
|
||||
use std::env::var;
|
||||
use std::error::Error;
|
||||
use std::io::{Read, Write};
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::models::client::{payload::Payload,
|
||||
payload::OpCode,
|
||||
commands::Commands};
|
||||
use crate::models::client::{commands::Commands, payload::OpCode, payload::Payload};
|
||||
|
||||
pub struct DiscordClient {
|
||||
pub id: String,
|
||||
|
|
@ -23,7 +21,9 @@ impl DiscordClient {
|
|||
socket: None,
|
||||
};
|
||||
|
||||
client.connect().expect("Could not connect to client. Is Discord running ?");
|
||||
client
|
||||
.connect()
|
||||
.expect("Could not connect to client. Is Discord running ?");
|
||||
client
|
||||
}
|
||||
|
||||
|
|
|
|||
17
src/lib.rs
17
src/lib.rs
|
|
@ -3,15 +3,8 @@ pub mod models;
|
|||
|
||||
pub use client::ipc::DiscordClient;
|
||||
pub use models::activity::Activity;
|
||||
pub use models::activity_data::{activity_flag::ActivityFlag,
|
||||
activity_type::ActivityType,
|
||||
asset::Asset,
|
||||
button::Button,
|
||||
emoji::Emoji,
|
||||
party::Party,
|
||||
secret::Secret,
|
||||
timestamp::Timestamp};
|
||||
pub use models::client::{payload::Payload,
|
||||
event::EventName,
|
||||
event::EventData};
|
||||
|
||||
pub use models::activity_data::{
|
||||
activity_flag::ActivityFlag, activity_type::ActivityType, asset::Asset, button::Button,
|
||||
emoji::Emoji, party::Party, secret::Secret, timestamp::Timestamp,
|
||||
};
|
||||
pub use models::client::{event::EventData, event::EventName, payload::Payload};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
use crate::models::activity_data::{
|
||||
activity_flag::ActivityFlag, activity_type::ActivityType, asset::Asset, button::Button,
|
||||
emoji::Emoji, party::Party, secret::Secret, timestamp::Timestamp,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use crate::models::activity_data::{activity_type::ActivityType,
|
||||
activity_flag::ActivityFlag,
|
||||
asset::Asset,
|
||||
button::Button,
|
||||
emoji::Emoji,
|
||||
party::Party,
|
||||
secret::Secret,
|
||||
timestamp::Timestamp, };
|
||||
|
||||
/// Test Doc
|
||||
#[derive(Serialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -16,16 +16,17 @@ pub struct Asset {
|
|||
}
|
||||
|
||||
impl Asset {
|
||||
pub fn new(large_image: Option<String>,
|
||||
large_text: Option<String>,
|
||||
small_image: Option<String>,
|
||||
small_text: Option<String>,
|
||||
pub fn new(
|
||||
large_image: Option<String>,
|
||||
large_text: Option<String>,
|
||||
small_image: Option<String>,
|
||||
small_text: Option<String>,
|
||||
) -> Asset {
|
||||
Self {
|
||||
large_image,
|
||||
large_text,
|
||||
small_image,
|
||||
small_text
|
||||
small_text,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,9 +8,6 @@ pub struct Button {
|
|||
|
||||
impl Button {
|
||||
pub fn new(label: String, url: String) -> Button {
|
||||
Self {
|
||||
label,
|
||||
url
|
||||
}
|
||||
Self { label, url }
|
||||
}
|
||||
}
|
||||
|
|
@ -8,17 +8,11 @@ pub struct Emoji {
|
|||
id: Option<i64>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
animated: Option<bool>
|
||||
animated: Option<bool>,
|
||||
}
|
||||
|
||||
impl Emoji {
|
||||
pub fn new(name: String,
|
||||
id: Option<i64>,
|
||||
animated: Option<bool>) -> Emoji {
|
||||
Self {
|
||||
name,
|
||||
id,
|
||||
animated
|
||||
}
|
||||
pub fn new(name: String, id: Option<i64>, animated: Option<bool>) -> Emoji {
|
||||
Self { name, id, animated }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
pub mod activity_flag;
|
||||
pub mod activity_type;
|
||||
pub mod timestamp;
|
||||
pub mod asset;
|
||||
pub mod button;
|
||||
pub mod emoji;
|
||||
pub mod party;
|
||||
pub mod asset;
|
||||
pub mod secret;
|
||||
pub mod activity_flag;
|
||||
pub mod button;
|
||||
pub mod timestamp;
|
||||
|
|
|
|||
|
|
@ -6,14 +6,11 @@ pub struct Party {
|
|||
id: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
size: Option<(i8, i8)>
|
||||
size: Option<(i8, i8)>,
|
||||
}
|
||||
|
||||
impl Party {
|
||||
pub fn new(id: Option<String>, size: Option<(i8, i8)>) -> Party {
|
||||
Self {
|
||||
id,
|
||||
size
|
||||
}
|
||||
Self { id, size }
|
||||
}
|
||||
}
|
||||
|
|
@ -9,18 +9,19 @@ pub struct Secret {
|
|||
spectate: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
instanced_match: Option<String>
|
||||
instanced_match: Option<String>,
|
||||
}
|
||||
|
||||
impl Secret {
|
||||
pub fn new(join: Option<String>,
|
||||
spectate: Option<String>,
|
||||
instanced_match: Option<String>) -> Secret {
|
||||
pub fn new(
|
||||
join: Option<String>,
|
||||
spectate: Option<String>,
|
||||
instanced_match: Option<String>,
|
||||
) -> Secret {
|
||||
Self {
|
||||
join,
|
||||
spectate,
|
||||
instanced_match
|
||||
instanced_match,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,11 +10,7 @@ pub struct Timestamp {
|
|||
}
|
||||
|
||||
impl Timestamp {
|
||||
pub fn new(start: Option<u128>,
|
||||
end: Option<u128>) -> Timestamp {
|
||||
Self {
|
||||
start,
|
||||
end,
|
||||
}
|
||||
pub fn new(start: Option<u128>, end: Option<u128>) -> Timestamp {
|
||||
Self { start, end }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
pub enum Commands {
|
||||
SetActivity
|
||||
SetActivity,
|
||||
}
|
||||
|
||||
impl Commands {
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@ use crate::models::activity::Activity;
|
|||
#[derive(Serialize, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum EventData {
|
||||
Activity(Activity)
|
||||
Activity(Activity),
|
||||
}
|
||||
|
||||
pub enum EventName {
|
||||
Activity
|
||||
Activity,
|
||||
}
|
||||
|
||||
|
||||
impl EventName {
|
||||
pub fn as_string(&self) -> String {
|
||||
match self {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
pub mod payload;
|
||||
pub mod event;
|
||||
pub mod commands;
|
||||
pub mod event;
|
||||
pub mod payload;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use serde::Serialize;
|
||||
use crate::models::client::event::{EventData, EventName};
|
||||
use serde::Serialize;
|
||||
|
||||
pub enum OpCode {
|
||||
HANDSHAKE,
|
||||
|
|
@ -16,7 +16,7 @@ impl Payload {
|
|||
pub fn new(event_name: EventName, event_data: EventData) -> Self {
|
||||
Self {
|
||||
event_name: event_name.as_string(),
|
||||
event_data
|
||||
event_data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
pub mod activity_data;
|
||||
pub mod activity;
|
||||
pub mod activity_data;
|
||||
pub mod client;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue