From cadaca90a1a0a9d36fdddfc557954560131b9392 Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:24:19 +0100 Subject: [PATCH] docs: fix doc warning, fix incorrect refrences to 'webrtc' --- src/api/guilds/messages.rs | 2 +- src/errors.rs | 8 ++++---- src/types/events/voice_gateway/identify.rs | 4 ++-- src/types/events/voice_gateway/mod.rs | 4 ++-- src/types/events/voice_gateway/ready.rs | 9 ++++++--- src/types/events/voice_gateway/select_protocol.rs | 4 +++- src/types/events/voice_gateway/speaking.rs | 2 +- src/types/events/voice_gateway/voice_backend_version.rs | 2 +- src/voice/crypto.rs | 8 ++++---- src/voice/gateway/message.rs | 5 ++++- src/voice/udp/handle.rs | 2 +- 11 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/api/guilds/messages.rs b/src/api/guilds/messages.rs index 60fd4e3..246d3cc 100644 --- a/src/api/guilds/messages.rs +++ b/src/api/guilds/messages.rs @@ -9,7 +9,7 @@ impl Guild { /// permission to be present on the current user. /// /// If the guild/channel you are searching is not yet indexed, the endpoint will return a 202 accepted response. - /// In this case, the method will return a [`ChorusError::InvalidResponse`] error. + /// In this case, the method will return a [`ChorusError::InvalidResponse`](crate::errors::ChorusError::InvalidResponse) error. /// /// # Reference: /// See diff --git a/src/errors.rs b/src/errors.rs index e129cf6..41cc97c 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -63,7 +63,7 @@ custom_error! { } custom_error! { - /// For errors we receive from the gateway, see https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#gateway-close-event-codes; + /// For errors we receive from the gateway, see ; /// /// Supposed to be sent as numbers, though they are sent as string most of the time? /// @@ -102,14 +102,14 @@ custom_error! { /// /// Similar to [GatewayError]. /// - /// See https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice; + /// See ; #[derive(Clone, Default, PartialEq, Eq)] pub VoiceGatewayError // Errors we receive #[default] UnknownOpcode = "You sent an invalid opcode", - FailedToDecodePayload = "You sent an invalid payload in your identifying to the (Webrtc) Gateway", - NotAuthenticated = "You sent a payload before identifying with the (Webrtc) Gateway", + FailedToDecodePayload = "You sent an invalid payload in your identifying to the (Voice) Gateway", + NotAuthenticated = "You sent a payload before identifying with the (Voice) Gateway", AuthenticationFailed = "The token you sent in your identify payload is incorrect", AlreadyAuthenticated = "You sent more than one identify payload", SessionNoLongerValid = "Your session is no longer valid", diff --git a/src/types/events/voice_gateway/identify.rs b/src/types/events/voice_gateway/identify.rs index 4021c28..686834e 100644 --- a/src/types/events/voice_gateway/identify.rs +++ b/src/types/events/voice_gateway/identify.rs @@ -2,9 +2,9 @@ use crate::types::{Snowflake, WebSocketEvent}; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)] -/// The identify payload for the webrtc stream; +/// The identify payload for the voice gateway connection; /// -/// Contains info to begin a webrtc connection; +/// Contains authentication info and context to authenticate to the voice gateway. /// /// See pub struct VoiceIdentify { diff --git a/src/types/events/voice_gateway/mod.rs b/src/types/events/voice_gateway/mod.rs index 23571f5..a4c344a 100644 --- a/src/types/events/voice_gateway/mod.rs +++ b/src/types/events/voice_gateway/mod.rs @@ -27,7 +27,7 @@ mod ssrc_definition; mod voice_backend_version; #[derive(Debug, Default, Serialize, Clone)] -/// The payload used for sending events to the webrtc gateway. +/// The payload used for sending events to the voice gateway. /// /// Similar to [VoiceGatewayReceivePayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue] pub struct VoiceGatewaySendPayload { @@ -41,7 +41,7 @@ pub struct VoiceGatewaySendPayload { impl WebSocketEvent for VoiceGatewaySendPayload {} #[derive(Debug, Deserialize, Clone)] -/// The payload used for receiving events from the webrtc gateway. +/// The payload used for receiving events from the voice gateway. /// /// Note that this is similar to the regular gateway, except we no longer have s or t /// diff --git a/src/types/events/voice_gateway/ready.rs b/src/types/events/voice_gateway/ready.rs index 8b6ef8e..eb3d433 100644 --- a/src/types/events/voice_gateway/ready.rs +++ b/src/types/events/voice_gateway/ready.rs @@ -6,9 +6,12 @@ use serde::{Deserialize, Serialize}; use super::VoiceEncryptionMode; #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] -/// The ready event for the webrtc stream; +/// The voice gateway's ready event; /// -/// Used to give info after the identify event; +/// Gives the user info about the udp connection ip and port, srrc to use, +/// available encryption modes and other data. +/// +/// Sent in response to an Identify event. /// /// See pub struct VoiceReady { @@ -16,7 +19,7 @@ pub struct VoiceReady { pub ssrc: u32, pub ip: Ipv4Addr, pub port: u16, - /// The available encryption modes for the webrtc connection + /// The available encryption modes for the udp connection pub modes: Vec, #[serde(default)] pub experiments: Vec, diff --git a/src/types/events/voice_gateway/select_protocol.rs b/src/types/events/voice_gateway/select_protocol.rs index 38d674a..afdd86a 100644 --- a/src/types/events/voice_gateway/select_protocol.rs +++ b/src/types/events/voice_gateway/select_protocol.rs @@ -3,7 +3,8 @@ use serde::{Deserialize, Serialize}; use super::VoiceEncryptionMode; #[derive(Debug, Deserialize, Serialize, Clone, Default)] -/// An event sent by the client to the webrtc server, detailing what protocol, address and encryption to use; +/// An event sent by the client to the voice gateway server, +/// detailing what protocol, address and encryption to use; /// /// See pub struct SelectProtocol { @@ -39,6 +40,7 @@ pub enum VoiceProtocol { /// See pub struct SelectProtocolData { /// Our external ip + // FIXME: This is a string pub address: Vec, /// Our external udp port pub port: u16, diff --git a/src/types/events/voice_gateway/speaking.rs b/src/types/events/voice_gateway/speaking.rs index c31e7e1..95810a0 100644 --- a/src/types/events/voice_gateway/speaking.rs +++ b/src/types/events/voice_gateway/speaking.rs @@ -12,7 +12,7 @@ use crate::types::{Snowflake, WebSocketEvent}; pub struct Speaking { /// Data about the audio we're transmitting. /// - /// See [SpeakingBitFlags] + /// See [SpeakingBitflags] pub speaking: u8, pub ssrc: u32, /// The user id of the speaking user, only sent by the server diff --git a/src/types/events/voice_gateway/voice_backend_version.rs b/src/types/events/voice_gateway/voice_backend_version.rs index 6b788ea..6ee0370 100644 --- a/src/types/events/voice_gateway/voice_backend_version.rs +++ b/src/types/events/voice_gateway/voice_backend_version.rs @@ -2,7 +2,7 @@ use crate::types::WebSocketEvent; use serde::{Deserialize, Serialize}; #[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq)] -/// Received from the server to describe the backend version. +/// Received from the voice gateway server to describe the backend version. /// /// See pub struct VoiceBackendVersion { diff --git a/src/voice/crypto.rs b/src/voice/crypto.rs index 581d938..86b1303 100644 --- a/src/voice/crypto.rs +++ b/src/voice/crypto.rs @@ -1,8 +1,8 @@ //! Defines cryptography functions used within the voice implementation. //! -//! All functions in this module return a 24 byte long [Vec]. +//! All functions in this module return a 24 byte long `Vec`. -/// Gets an xsalsa20_poly1305 nonce from an rtppacket. +/// Gets an `xsalsa20_poly1305` nonce from an rtppacket. /// /// See pub(crate) fn get_xsalsa20_poly1305_nonce(packet: &[u8]) -> Vec { @@ -17,7 +17,7 @@ pub(crate) fn get_xsalsa20_poly1305_nonce(packet: &[u8]) -> Vec { rtp_header } -/// Gets an xsalsa20_poly1305_suffix nonce from an rtppacket. +/// Gets an `xsalsa20_poly1305_suffix` nonce from an rtppacket. /// /// See pub(crate) fn get_xsalsa20_poly1305_suffix_nonce(packet: &[u8]) -> Vec { @@ -28,7 +28,7 @@ pub(crate) fn get_xsalsa20_poly1305_suffix_nonce(packet: &[u8]) -> Vec { nonce } -/// Gets an xsalsa20_poly1305_lite nonce from an rtppacket. +/// Gets an `xsalsa20_poly1305_lite` nonce from an rtppacket. /// /// See pub(crate) fn get_xsalsa20_poly1305_lite_nonce(packet: &[u8]) -> Vec { diff --git a/src/voice/gateway/message.rs b/src/voice/gateway/message.rs index ebda848..623f849 100644 --- a/src/voice/gateway/message.rs +++ b/src/voice/gateway/message.rs @@ -1,6 +1,9 @@ use crate::{errors::VoiceGatewayError, types::VoiceGatewayReceivePayload}; -/// Represents a messsage received from the webrtc socket. This will be either a [GatewayReceivePayload], containing webrtc events, or a [WebrtcError]. +/// Represents a messsage received from the voice websocket connection. +/// +/// This will be either a [VoiceGatewayReceivePayload], containing voice gateway events, or a [VoiceGatewayError]. +/// /// This struct is used internally when handling messages. #[derive(Clone, Debug)] pub struct VoiceGatewayMessage(pub String); diff --git a/src/voice/udp/handle.rs b/src/voice/udp/handle.rs index 1fab085..c45d5c2 100644 --- a/src/voice/udp/handle.rs +++ b/src/voice/udp/handle.rs @@ -33,7 +33,7 @@ pub struct UdpHandle { impl UdpHandle { /// Constructs and sends encoded opus rtp data. /// - /// Automatically makes an [RtpPacket](discorrtp::rtp::RtpPacket), encrypts it and sends it. + /// Automatically makes an [RtpPacket](discortp::rtp::RtpPacket), encrypts it and sends it. /// /// # Errors /// If we do not have VoiceReady data, which contains our ssrc, this returns a