From eee62e0892b1247ce321cd30747ab90d58f49732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 13 Jan 2021 23:19:22 +0100 Subject: document mumlib --- mumlib/src/command.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'mumlib/src/command.rs') diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index 8cb7cb9..642c8b9 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -1,3 +1,7 @@ +//! [Command]s can be sent from a controller to mumd who might respond with a +//! [CommandResponse]. The commands and their responses are serializable and +//! can be sent in any way you want. + use crate::state::{Channel, Server}; use chrono::NaiveDateTime; @@ -56,29 +60,51 @@ impl fmt::Display for MumbleEventKind { } } +/// Sent by a controller to mumd who might respond with a [CommandResponse]. Not +/// all commands receive a response. #[derive(Clone, Debug, Deserialize, Serialize)] pub enum Command { + /// No response. ChannelJoin { channel_identifier: String, }, + + /// Response: [CommandResponse::ChannelList]. ChannelList, + + /// Force reloading of config file from disk. No response. ConfigReload, + /// Response: [CommandResponse::DeafenStatus]. Toggles if None. DeafenSelf(Option), Events { block: bool }, + /// Set the outgoing audio volume (i.e. from you to the server). No response. InputVolumeSet(f32), + + /// Response: [CommandResponse::MuteStatus]. Toggles if None. MuteOther(String, Option), + + /// Response: [CommandResponse::MuteStatus]. Toggles if None. MuteSelf(Option), + + /// Set the master incoming audio volume (i.e. from the server to you). + /// No response. OutputVolumeSet(f32), + PastMessages { block: bool, }, + + /// Response: [CommandResponse::Pong]. Used to test existance of a + /// mumd-instance. Ping, + SendMessage { message: String, targets: MessageTarget, }, + /// Connect to the specified server. Response: [CommandResponse::ServerConnect]. ServerConnect { host: String, port: u16, @@ -86,43 +112,61 @@ pub enum Command { password: Option, accept_invalid_cert: bool, }, + + /// No response. ServerDisconnect, + + /// Send a server status request via UDP (e.g. not requiring a TCP connection). + /// Response: [CommandResponse::ServerStatus]. ServerStatus { host: String, port: u16, }, + + /// Response: [CommandResponse::Status]. Status, + + /// No response. UserVolumeSet(String, f32), } +/// A response to a sent [Command]. #[derive(Debug, Deserialize, Serialize)] pub enum CommandResponse { ChannelList { channels: Channel, }, + DeafenStatus { is_deafened: bool, }, + Event { event: MumbleEvent, }, + MuteStatus { is_muted: bool, }, + PastMessage { message: (NaiveDateTime, String, String), }, + Pong, + ServerConnect { welcome_message: Option, server_state: Server, }, + ServerStatus { version: u32, users: u32, max_users: u32, bandwidth: u32, }, + Status { server_state: Server, }, -- cgit v1.2.1 From ed4b641f6d4816325aa07e0f13b6132c1c4dafa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 15 Jun 2021 12:50:01 +0200 Subject: more mumlib doc just because --- mumlib/src/command.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mumlib/src/command.rs') diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index 642c8b9..3c56130 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -11,7 +11,9 @@ use std::fmt; /// Something that happened in our channel at a point in time. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct MumbleEvent { + /// When the event occured. pub timestamp: NaiveDateTime, + /// What occured. pub kind: MumbleEventKind } @@ -24,11 +26,17 @@ impl fmt::Display for MumbleEvent { /// The different kinds of events that can happen. #[derive(Debug, Clone, Serialize, Deserialize)] pub enum MumbleEventKind { + /// A user connected to the server and joined our channel. Contains `(user, channel)`. UserConnected(String, String), + /// A user disconnected from the server while in our channel. Contains `(user, channel)`. UserDisconnected(String, String), + /// A user {un,}{muted,deafened}. Contains a rendered message with what changed and the user. UserMuteStateChanged(String), // This logic is kinda weird so we only store the rendered message. + /// A text message was received. Contains who sent the message. TextMessageReceived(String), + /// A user switched to our channel from some other channel. Contains `(user, previous-channel)`. UserJoinedChannel(String, String), + /// A user switched from our channel to some other channel. Contains `(user, new-channel)`. UserLeftChannel(String, String), } -- cgit v1.2.1 From f03d0d1d8def80c905a59c2bba9722d21a95ffae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 15 Jun 2021 13:30:45 +0200 Subject: remove cruft --- mumlib/src/command.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'mumlib/src/command.rs') diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index 3c56130..79343cf 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -1,6 +1,5 @@ -//! [Command]s can be sent from a controller to mumd who might respond with a -//! [CommandResponse]. The commands and their responses are serializable and -//! can be sent in any way you want. +//! [Command]s can be sent from a controller to mumd which might respond with a +//! [CommandResponse]. use crate::state::{Channel, Server}; -- cgit v1.2.1 From 14ecdfe2365682e37df99569747b96943ec55426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Tue, 15 Jun 2021 13:41:45 +0200 Subject: doc mumlib state --- mumlib/src/command.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'mumlib/src/command.rs') diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index 79343cf..9d98a38 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -89,16 +89,18 @@ pub enum Command { /// Set the outgoing audio volume (i.e. from you to the server). No response. InputVolumeSet(f32), - /// Response: [CommandResponse::MuteStatus]. Toggles if None. + /// Response: [CommandResponse::MuteStatus]. Toggles mute state if None. MuteOther(String, Option), - /// Response: [CommandResponse::MuteStatus]. Toggles if None. + /// Response: [CommandResponse::MuteStatus]. Toggles mute state if None. MuteSelf(Option), /// Set the master incoming audio volume (i.e. from the server to you). /// No response. OutputVolumeSet(f32), + /// Request a list of past messages. Blocks while waiting for more messages + /// if block is true. Response: multiple [CommandResponse::PastMessage]. PastMessages { block: bool, }, @@ -107,20 +109,29 @@ pub enum Command { /// mumd-instance. Ping, + /// Send a message to some [MessageTarget]. SendMessage { + /// The message to send. message: String, + /// The target(s) to send the message to. targets: MessageTarget, }, + /// Connect to the specified server. Response: [CommandResponse::ServerConnect]. ServerConnect { + /// The URL or IP-adress to connect to. host: String, + /// The port to connect to. port: u16, + /// The username to connect with. username: String, + /// The server password, if applicable. Not sent if None. password: Option, + /// Whether to accept an invalid server certificate or not. accept_invalid_cert: bool, }, - /// No response. + /// Disconnect from the currently connected server. No response. ServerDisconnect, /// Send a server status request via UDP (e.g. not requiring a TCP connection). @@ -130,10 +141,10 @@ pub enum Command { port: u16, }, - /// Response: [CommandResponse::Status]. + /// Request the status of the current server. Response: [CommandResponse::Status]. Status, - /// No response. + /// The the volume of the specified user. No response. UserVolumeSet(String, f32), } -- cgit v1.2.1