diff options
Diffstat (limited to 'mumlib/src/state.rs')
| -rw-r--r-- | mumlib/src/state.rs | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index ef25a79..b6b4039 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -1,3 +1,4 @@ +use mumble_protocol::control::msgs; use serde::export::Formatter; use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -116,7 +117,7 @@ impl<'a> Iterator for UsersIter<'a> { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct User { - pub comment: Option<String>, + pub comment: Option<String>, //TODO not option, empty string instead pub hash: Option<String>, pub name: String, pub priority_speaker: bool, @@ -148,6 +149,8 @@ pub struct UserDiff { 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 { @@ -155,3 +158,43 @@ impl UserDiff { 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 + } +} |
