Minor doc fixes

This commit is contained in:
kozabrada123 2023-10-14 08:53:31 +02:00
parent 06ea17875f
commit efc2fe2ba3
5 changed files with 30 additions and 21 deletions

View File

@ -3,8 +3,10 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)]
/// The identify payload for the webrtc stream;
///
/// Contains info to begin a webrtc connection;
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload;
///
/// See <https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-identify-payload>
pub struct VoiceIdentify {
server_id: Snowflake,
user_id: Snowflake,

View File

@ -1,5 +1,6 @@
use super::WebSocketEvent;
use serde::{Deserialize, Serialize};
use serde_json::{value::RawValue, Value};
pub use identify::*;
pub use ready::*;
@ -14,40 +15,38 @@ mod session_description;
mod speaking;
#[derive(Debug, Default, Serialize, Clone)]
/// The payload used for sending events to the webrtc gateway
/// Not tha this is very similar to the regular gateway, except we no longer have a sequence number
/// The payload used for sending events to the webrtc gateway.
///
/// Similar to [WebrtcReceivePayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue]
/// Also, we never need to send the event name
/// Similar to [VoiceGatewayReceivePayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue]
pub struct VoiceGatewaySendPayload {
#[serde(rename = "op")]
pub op_code: u8,
#[serde(rename = "d")]
pub data: serde_json::Value,
pub data: Value,
}
impl WebSocketEvent for VoiceGatewaySendPayload {}
#[derive(Debug, Deserialize, Clone)]
/// The payload used for receiving events from the webrtc gateway
/// Note that this is very similar to the regular gateway, except we no longer have s or t
/// The payload used for receiving events from the webrtc gateway.
///
/// Similar to [WebrtcSendPayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue]
/// Also, we never need to sent the event name
/// Note that this is similar to the regular gateway, except we no longer have s or t
///
/// Similar to [VoiceGatewaySendPayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue]
pub struct VoiceGatewayReceivePayload<'a> {
#[serde(rename = "op")]
pub op_code: u8,
#[serde(borrow)]
#[serde(rename = "d")]
pub data: &'a serde_json::value::RawValue,
pub data: &'a RawValue,
}
impl<'a> WebSocketEvent for VoiceGatewayReceivePayload<'a> {}
/// The modes of encryption available in webrtc connections;
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-encryption-modes;
/// See <https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-encryption-modes>
#[derive(Debug, Default, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum WebrtcEncryptionMode {
@ -68,9 +67,9 @@ pub const VOICE_HEARTBEAT_ACK: u8 = 6;
pub const VOICE_RESUME: u8 = 7;
pub const VOICE_HELLO: u8 = 8;
pub const VOICE_RESUMED: u8 = 9;
/// See https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#voice-opcodes
/// See <https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#voice-opcodes>
pub const VOICE_VIDEO: u8 = 12;
pub const VOICE_CLIENT_DISCONENCT: u8 = 13;
/// See https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#voice-opcodes;
/// See <https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#voice-opcodes>
/// Sent with empty data from the client, the server responds with the voice backend version;
pub const VOICE_BACKEND_VERSION: u8 = 16;

View File

@ -7,10 +7,12 @@ use super::WebrtcEncryptionMode;
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
/// The ready event for the webrtc stream;
///
/// Used to give info after the identify event;
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload;
///
/// See <https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-websocket-connection-example-voice-ready-payload>
pub struct VoiceReady {
/// See https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats/ssrc
/// See <https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpStreamStats/ssrc>
ssrc: i32,
ip: Ipv4Addr,
port: u32,

View File

@ -6,15 +6,18 @@ use super::WebrtcEncryptionMode;
#[derive(Debug, Deserialize, Serialize, Clone)]
/// An event sent by the client to the webrtc server, detailing what protocol, address and encryption to use;
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload
///
/// See <https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload>
pub struct SelectProtocol {
/// The protocol to use. The only option detailed in discord docs is "udp"
pub protocol: String,
pub data: SelectProtocolData,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
/// The data field of the SelectProtocol Event
/// See https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload;
///
/// See <https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload>
pub struct SelectProtocolData {
/// Our external ip
pub address: Ipv4Addr,

View File

@ -2,8 +2,10 @@ use bitflags::bitflags;
use serde::{Deserialize, Serialize};
/// Event that tells the server we are speaking;
/// Essentially, what allows us to send udp data and lights up the green circle around your avatar;
/// See https://discord.com/developers/docs/topics/voice-connections#speaking-example-speaking-payload
///
/// Essentially, what allows us to send udp data and lights up the green circle around your avatar.
///
/// See <https://discord.com/developers/docs/topics/voice-connections#speaking-example-speaking-payload>
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
pub struct Speaking {
/// Data about the audio we're transmitting, its type
@ -15,7 +17,8 @@ pub struct Speaking {
bitflags! {
/// Bitflags of speaking types;
/// See https://discord.com/developers/docs/topics/voice-connections#speaking;
///
/// See <https://discord.com/developers/docs/topics/voice-connections#speaking>
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Serialize, Deserialize)]
pub struct SpeakingBitflags: u8 {
/// Whether we'll be transmitting normal voice audio