From b72ebf36ed9af0fa09b588346d3ad59cd3aedae7 Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Sun, 30 Jul 2023 08:26:26 +0200 Subject: [PATCH] Documemtaiom --- src/api/auth/login.rs | 1 + src/api/auth/register.rs | 1 + src/api/channels/channels.rs | 20 ++++++++++++++++++-- src/api/channels/messages.rs | 9 ++++++++- src/api/channels/permissions.rs | 6 ++++++ src/api/users/users.rs | 19 +++++++++++++++++++ src/types/entities/channel.rs | 32 ++++++++++++++++++++++++++++++++ src/types/utils/snowflake.rs | 2 ++ 8 files changed, 87 insertions(+), 3 deletions(-) diff --git a/src/api/auth/login.rs b/src/api/auth/login.rs index 60ee52b..4cc58bb 100644 --- a/src/api/auth/login.rs +++ b/src/api/auth/login.rs @@ -13,6 +13,7 @@ use crate::types::{GatewayIdentifyPayload, LoginResult, LoginSchema}; impl Instance { /// Logs into an existing account on the spacebar server. + // TODO: Couldn't find reference pub async fn login_account(&mut self, login_schema: &LoginSchema) -> ChorusResult { let endpoint_url = self.urls.api.clone() + "/auth/login"; let chorus_request = ChorusRequest { diff --git a/src/api/auth/register.rs b/src/api/auth/register.rs index 630ad9d..ae41c47 100644 --- a/src/api/auth/register.rs +++ b/src/api/auth/register.rs @@ -15,6 +15,7 @@ use crate::{ impl Instance { /// Registers a new user on the server. + // TODO: Couldn't find reference pub async fn register_account( &mut self, register_schema: &RegisterSchema, diff --git a/src/api/channels/channels.rs b/src/api/channels/channels.rs index db94056..0f6d64a 100644 --- a/src/api/channels/channels.rs +++ b/src/api/channels/channels.rs @@ -12,6 +12,9 @@ use crate::{ impl Channel { /// Retrieves a channel from the server. + /// + /// # Reference + /// See pub async fn get(user: &mut UserMeta, channel_id: Snowflake) -> ChorusResult { let url = user.belongs_to.borrow().urls.api.clone(); let chorus_request = ChorusRequest { @@ -24,6 +27,9 @@ impl Channel { } /// Deletes self. + /// + /// # Reference + /// See pub async fn delete(self, user: &mut UserMeta) -> ChorusResult<()> { let chorus_request = ChorusRequest { request: Client::new() @@ -40,6 +46,9 @@ impl Channel { /// Modifies a channel with the provided data. /// Returns the new Channel. + /// + /// # Reference + /// See pub async fn modify( &self, modify_data: ChannelModifySchema, @@ -61,6 +70,9 @@ impl Channel { } /// Fetches recent messages from a channel. + /// + /// # Reference + /// See pub async fn messages( range: GetChannelMessagesSchema, channel_id: Snowflake, @@ -83,8 +95,10 @@ impl Channel { .await } + /// Adds a recipient to a group DM. + /// /// # Reference: - /// Read: + /// See pub async fn add_channel_recipient( &self, recipient_id: Snowflake, @@ -110,8 +124,10 @@ impl Channel { .await } + /// Removes a recipient from a group DM. + /// /// # Reference: - /// Read: + /// See pub async fn remove_channel_recipient( &self, recipient_id: Snowflake, diff --git a/src/api/channels/messages.rs b/src/api/channels/messages.rs index 9c06f6f..5f1745b 100644 --- a/src/api/channels/messages.rs +++ b/src/api/channels/messages.rs @@ -12,6 +12,9 @@ use crate::types::{Message, MessageSendSchema, Snowflake}; impl Message { /// Sends a message in the channel with the provided channel_id. /// Returns the sent message. + /// + /// # Reference + /// See pub async fn send( user: &mut UserMeta, channel_id: Snowflake, @@ -71,8 +74,12 @@ impl Message { impl UserMeta { /// Sends a message in the channel with the provided channel_id. /// Returns the sent message. + /// /// # Notes - /// Shorthand call for Message::send() + /// Shorthand call for [`Message::send`] + /// + /// # Reference + /// See pub async fn send_message( &mut self, message: MessageSendSchema, diff --git a/src/api/channels/permissions.rs b/src/api/channels/permissions.rs index 57feb5d..d68034e 100644 --- a/src/api/channels/permissions.rs +++ b/src/api/channels/permissions.rs @@ -11,6 +11,9 @@ use crate::{ impl types::Channel { /// Edits the permission overwrites for a channel. + /// + /// # Reference + /// See pub async fn edit_permissions( user: &mut UserMeta, channel_id: Snowflake, @@ -38,6 +41,9 @@ impl types::Channel { } /// Deletes a permission overwrite for a channel. + /// + /// # Reference + /// See pub async fn delete_permission( user: &mut UserMeta, channel_id: Snowflake, diff --git a/src/api/users/users.rs b/src/api/users/users.rs index f673ee3..16c2560 100644 --- a/src/api/users/users.rs +++ b/src/api/users/users.rs @@ -16,6 +16,10 @@ impl UserMeta { /// /// # Notes /// This function is a wrapper around [`User::get`]. + /// + /// # Reference + /// See and + /// pub async fn get(user: &mut UserMeta, id: Option<&String>) -> ChorusResult { User::get(user, id).await } @@ -33,6 +37,9 @@ impl UserMeta { } /// Modifies the current user's representation. (See [`User`]) + /// + /// # Reference + /// See pub async fn modify(&mut self, modify_schema: UserModifySchema) -> ChorusResult { if modify_schema.new_password.is_some() || modify_schema.email.is_some() @@ -57,6 +64,9 @@ impl UserMeta { } /// Deletes the user from the Instance. + /// + /// # Reference + /// See pub async fn delete(mut self) -> ChorusResult<()> { let request = Client::new() .post(format!( @@ -74,6 +84,10 @@ impl UserMeta { impl User { /// Gets a user by id, or if the id is None, gets the current user. + /// + /// # Reference + /// See and + /// pub async fn get(user: &mut UserMeta, id: Option<&String>) -> ChorusResult { let url_api = user.belongs_to.borrow().urls.api.clone(); let url = if id.is_none() { @@ -96,6 +110,7 @@ impl User { } /// Gets the user's settings. + // TODO: Couldn't find reference pub async fn get_settings( token: &String, url_api: &String, @@ -127,6 +142,10 @@ impl Instance { /// /// # Notes /// This function is a wrapper around [`User::get`]. + /// + /// # Reference + /// See and + /// pub async fn get_user(&mut self, token: String, id: Option<&String>) -> ChorusResult { let mut user = UserMeta::shell(Rc::new(RefCell::new(self.clone())), token).await; let result = User::get(&mut user, id).await; diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index 154b83c..98aa9ed 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -12,6 +12,10 @@ use crate::types::{ #[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Updateable)] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] +/// Represents a guild of private channel +/// +/// # Reference +/// See pub struct Channel { pub application_id: Option, #[cfg(feature = "sqlx")] @@ -120,27 +124,55 @@ pub struct DefaultReaction { #[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[repr(i32)] +/// # Reference +/// See pub enum ChannelType { #[default] + /// A text channel within a guild GuildText = 0, + /// A private channel between two users Dm = 1, + /// A voice channel within a guild GuildVoice = 2, + /// A private channel between multiple users GroupDm = 3, + /// An organizational category that contains up to 50 channels GuildCategory = 4, + /// Similar to [GuildText], a channel that users can follow and crosspost into their own guild GuildNews = 5, + /// A channel in which game developers can sell their game on Discord + /// + /// # Note + /// Deprecated. GuildStore = 6, + // FIXME userdoccers says 7 is GuildLfg, is this a spacebar specific thing? Encrypted = 7, + // FIXME userdoccers says 8 is LfgGuildDm, is this a spacebar specific thing? EncryptedThreads = 8, + // FIXME userdoccers says 9 is ThreadAlpha, was this changed? Transactional = 9, + /// A thread within a [GuildNews] channel GuildNewsThread = 10, + /// A thread within a [GuildText], [GuildForum], or [GuildMedia] channel GuildPublicThread = 11, + /// A thread within a [GuildText] channel, that is only viewable by those invited and those with the [ManageThreads] permission GuildPrivateThread = 12, + /// A voice channel for hosting events with an audience in a guild GuildStageVoice = 13, + /// The main channel in a hub containing the listed guilds Directory = 14, + /// A channel that can only contain threads GuildForum = 15, + /// A channel that can only contain threads in a gallery view + GuildMedia = 16, + // TODO: Couldn't find reference TicketTracker = 33, + // TODO: Couldn't find reference Kanban = 34, + // TODO: Couldn't find reference VoicelessWhiteboard = 35, + // TODO: Couldn't find reference CustomStart = 64, + // TODO: Couldn't find reference Unhandled = 255, } diff --git a/src/types/utils/snowflake.rs b/src/types/utils/snowflake.rs index 9796084..a9f572b 100644 --- a/src/types/utils/snowflake.rs +++ b/src/types/utils/snowflake.rs @@ -11,6 +11,8 @@ use sqlx::Type; const EPOCH: i64 = 1420070400000; /// Unique identifier including a timestamp. +/// +/// # Reference /// See #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] #[cfg_attr(feature = "sqlx", derive(Type))]