diff options
| author | Kapten Z∅∅m <55669224+default-username-852@users.noreply.github.com> | 2020-12-24 06:53:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-24 06:53:19 +0100 |
| commit | 58947a7a3acaa1ae04887723643a49db76479f00 (patch) | |
| tree | 66aeb40782bdb904adb21e6940679cb432ff0d83 | |
| parent | c38ec422588c5b5f1f6701a698dff5eeff30f0f2 (diff) | |
| parent | ded5b573004f867bc9fe9644d4d4fe3a81c48b99 (diff) | |
| download | mum-58947a7a3acaa1ae04887723643a49db76479f00.tar.gz | |
Merge pull request #32 from sornas/mumble-protocol-cleanup
remove mumlibs dependency on rust-mumble-protocol
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | mumd/src/state.rs | 2 | ||||
| -rw-r--r-- | mumd/src/state/user.rs | 65 | ||||
| -rw-r--r-- | mumlib/Cargo.toml | 1 | ||||
| -rw-r--r-- | mumlib/src/state.rs | 66 |
5 files changed, 66 insertions, 69 deletions
@@ -842,7 +842,6 @@ dependencies = [ "colored", "fern", "log", - "mumble-protocol", "serde", "toml", ] diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 7a4704a..aba0931 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -16,7 +16,7 @@ use mumble_protocol::voice::Serverbound; use mumlib::command::{Command, CommandResponse}; use mumlib::config::Config; use mumlib::error::{ChannelIdentifierError, Error}; -use mumlib::state::UserDiff; +use crate::state::user::UserDiff; use std::net::{SocketAddr, ToSocketAddrs}; use tokio::sync::{mpsc, watch}; diff --git a/mumd/src/state/user.rs b/mumd/src/state/user.rs index 913f91b..5770bca 100644 --- a/mumd/src/state/user.rs +++ b/mumd/src/state/user.rs @@ -78,7 +78,7 @@ impl User { } } - pub fn apply_user_diff(&mut self, diff: &mumlib::state::UserDiff) { + pub fn apply_user_diff(&mut self, diff: &crate::state::user::UserDiff) { if let Some(comment) = diff.comment.clone() { self.comment = Some(comment); } @@ -155,3 +155,66 @@ impl From<&User> for mumlib::state::User { } } } + +#[derive(Debug, Default)] +pub struct UserDiff { + pub comment: Option<String>, + pub hash: Option<String>, + pub name: Option<String>, + pub priority_speaker: Option<bool>, + pub recording: Option<bool>, + + pub suppress: Option<bool>, // by me + pub self_mute: Option<bool>, // by self + pub self_deaf: Option<bool>, // by self + pub mute: Option<bool>, // by admin + pub deaf: Option<bool>, // by admin + + pub channel_id: Option<u32>, +} + +impl UserDiff { + pub fn new() -> Self { + UserDiff::default() + } +} + +impl From<msgs::UserState> for UserDiff { + fn from(mut msg: msgs::UserState) -> Self { + let mut ud = UserDiff::new(); + if msg.has_comment() { + ud.comment = Some(msg.take_comment()); + } + if msg.has_hash() { + ud.hash = Some(msg.take_hash()); + } + if msg.has_name() { + ud.name = Some(msg.take_name()); + } + if msg.has_priority_speaker() { + ud.priority_speaker = Some(msg.get_priority_speaker()); + } + if msg.has_recording() { + ud.recording = Some(msg.get_recording()); + } + if msg.has_suppress() { + ud.suppress = Some(msg.get_suppress()); + } + if msg.has_self_mute() { + ud.self_mute = Some(msg.get_self_mute()); + } + if msg.has_self_deaf() { + ud.self_deaf = Some(msg.get_self_deaf()); + } + if msg.has_mute() { + ud.mute = Some(msg.get_mute()); + } + if msg.has_deaf() { + ud.deaf = Some(msg.get_deaf()); + } + if msg.has_channel_id() { + ud.channel_id = Some(msg.get_channel_id()); + } + ud + } +} diff --git a/mumlib/Cargo.toml b/mumlib/Cargo.toml index 59feb75..74bdb32 100644 --- a/mumlib/Cargo.toml +++ b/mumlib/Cargo.toml @@ -11,6 +11,5 @@ edition = "2018" colored = "2.0" fern = "0.5" log = "0.4" -mumble-protocol = "0.3" serde = { version = "1.0", features = ["derive"] } toml = "0.5" diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index 3b1da56..0f1cef2 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -1,4 +1,3 @@ -use mumble_protocol::control::msgs; use serde::export::Formatter; use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -153,67 +152,4 @@ impl Display for User { true_to_str!(self.deaf, "d") ) } -} - -#[derive(Debug, Default)] -pub struct UserDiff { - pub comment: Option<String>, - pub hash: Option<String>, - pub name: Option<String>, - pub priority_speaker: Option<bool>, - pub recording: Option<bool>, - - pub suppress: Option<bool>, // by me - pub self_mute: Option<bool>, // by self - pub self_deaf: Option<bool>, // by self - pub mute: Option<bool>, // by admin - pub deaf: Option<bool>, // by admin - - pub channel_id: Option<u32>, -} - -impl UserDiff { - pub fn new() -> Self { - UserDiff::default() - } -} - -impl From<msgs::UserState> for UserDiff { - fn from(mut msg: msgs::UserState) -> Self { - let mut ud = UserDiff::new(); - if msg.has_comment() { - ud.comment = Some(msg.take_comment()); - } - if msg.has_hash() { - ud.hash = Some(msg.take_hash()); - } - if msg.has_name() { - ud.name = Some(msg.take_name()); - } - if msg.has_priority_speaker() { - ud.priority_speaker = Some(msg.get_priority_speaker()); - } - if msg.has_recording() { - ud.recording = Some(msg.get_recording()); - } - if msg.has_suppress() { - ud.suppress = Some(msg.get_suppress()); - } - if msg.has_self_mute() { - ud.self_mute = Some(msg.get_self_mute()); - } - if msg.has_self_deaf() { - ud.self_deaf = Some(msg.get_self_deaf()); - } - if msg.has_mute() { - ud.mute = Some(msg.get_mute()); - } - if msg.has_deaf() { - ud.deaf = Some(msg.get_deaf()); - } - if msg.has_channel_id() { - ud.channel_id = Some(msg.get_channel_id()); - } - ud - } -} +}
\ No newline at end of file |
