From a0d2fc82133a0e429345991f29cb801a21d5eba4 Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:54:04 +0200 Subject: [PATCH] Add some docs --- src/api/auth/login.rs | 1 + src/api/auth/register.rs | 10 +--------- src/api/channels/channels.rs | 32 +++++--------------------------- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/src/api/auth/login.rs b/src/api/auth/login.rs index baae4ae..1109fb8 100644 --- a/src/api/auth/login.rs +++ b/src/api/auth/login.rs @@ -11,6 +11,7 @@ use crate::ratelimiter::ChorusRequest; use crate::types::{LoginResult, LoginSchema}; impl Instance { + /// Logs into an existing account on the spacebar server. 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 e7b9d48..fa3d6c9 100644 --- a/src/api/auth/register.rs +++ b/src/api/auth/register.rs @@ -12,15 +12,7 @@ use crate::{ }; impl Instance { - /// Registers a new user on the Spacebar server. - /// - /// # Arguments - /// - /// * `register_schema` - The [`RegisterSchema`] that contains all the information that is needed to register a new user. - /// - /// # Errors - /// - /// * [`crate::errors::ChorusError`] - If the server does not respond. + /// Registers a new user on the server. 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 82662e3..9cb65a9 100644 --- a/src/api/channels/channels.rs +++ b/src/api/channels/channels.rs @@ -10,6 +10,7 @@ use crate::{ }; impl Channel { + /// Retrieves a channel from the server. pub async fn get(user: &mut UserMeta, channel_id: Snowflake) -> ChorusResult { let url = user.belongs_to.borrow().urls.api.clone(); let chorus_request = ChorusRequest { @@ -21,19 +22,7 @@ impl Channel { chorus_request.deserialize_response::(user).await } - /// Deletes a channel. - /// - /// # Arguments - /// - /// * `token` - A string slice that holds the authorization token. - /// * `url_api` - A string slice that holds the URL of the API. - /// * `channel` - A `Channel` object that represents the channel to be deleted. - /// * `limits_user` - A mutable reference to a `Limits` object that represents the user's rate limits. - /// * `limits_instance` - A mutable reference to a `Limits` object that represents the instance's rate limits. - /// - /// # Returns - /// - /// A `Result` that contains a `ChorusLibError` if an error occurred during the request, or `()` if the request was successful. + /// Deletes self. pub async fn delete(self, user: &mut UserMeta) -> ChorusResult<()> { let chorus_request = ChorusRequest { request: Client::new() @@ -48,20 +37,8 @@ impl Channel { chorus_request.handle_request_as_result(user).await } - /// Modifies a channel. - /// - /// # Arguments - /// - /// * `modify_data` - A `ChannelModifySchema` object that represents the modifications to be made to the channel. - /// * `token` - A string slice that holds the authorization token. - /// * `url_api` - A string slice that holds the URL of the API. - /// * `channel_id` - A string slice that holds the ID of the channel to be modified. - /// * `limits_user` - A mutable reference to a `Limits` object that represents the user's rate limits. - /// * `limits_instance` - A mutable reference to a `Limits` object that represents the instance's rate limits. - /// - /// # Returns - /// - /// A `Result` that contains a `Channel` object if the request was successful, or an `ChorusLibError` if an error occurred during the request. + /// Modifies a channel with the provided data. + /// Replaces self with the new channel object. pub async fn modify( &mut self, modify_data: ChannelModifySchema, @@ -84,6 +61,7 @@ impl Channel { Ok(()) } + /// Fetches recent messages from a channel. pub async fn messages( range: GetChannelMessagesSchema, channel_id: Snowflake,