Add some docs
This commit is contained in:
parent
3b35f03993
commit
a0d2fc8213
|
@ -11,6 +11,7 @@ use crate::ratelimiter::ChorusRequest;
|
||||||
use crate::types::{LoginResult, LoginSchema};
|
use crate::types::{LoginResult, LoginSchema};
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
|
/// Logs into an existing account on the spacebar server.
|
||||||
pub async fn login_account(&mut self, login_schema: &LoginSchema) -> ChorusResult<UserMeta> {
|
pub async fn login_account(&mut self, login_schema: &LoginSchema) -> ChorusResult<UserMeta> {
|
||||||
let endpoint_url = self.urls.api.clone() + "/auth/login";
|
let endpoint_url = self.urls.api.clone() + "/auth/login";
|
||||||
let chorus_request = ChorusRequest {
|
let chorus_request = ChorusRequest {
|
||||||
|
|
|
@ -12,15 +12,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
/// Registers a new user on the Spacebar server.
|
/// Registers a new user on the 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.
|
|
||||||
pub async fn register_account(
|
pub async fn register_account(
|
||||||
&mut self,
|
&mut self,
|
||||||
register_schema: &RegisterSchema,
|
register_schema: &RegisterSchema,
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Channel {
|
impl Channel {
|
||||||
|
/// Retrieves a channel from the server.
|
||||||
pub async fn get(user: &mut UserMeta, channel_id: Snowflake) -> ChorusResult<Channel> {
|
pub async fn get(user: &mut UserMeta, channel_id: Snowflake) -> ChorusResult<Channel> {
|
||||||
let url = user.belongs_to.borrow().urls.api.clone();
|
let url = user.belongs_to.borrow().urls.api.clone();
|
||||||
let chorus_request = ChorusRequest {
|
let chorus_request = ChorusRequest {
|
||||||
|
@ -21,19 +22,7 @@ impl Channel {
|
||||||
chorus_request.deserialize_response::<Channel>(user).await
|
chorus_request.deserialize_response::<Channel>(user).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes a channel.
|
/// Deletes self.
|
||||||
///
|
|
||||||
/// # 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.
|
|
||||||
pub async fn delete(self, user: &mut UserMeta) -> ChorusResult<()> {
|
pub async fn delete(self, user: &mut UserMeta) -> ChorusResult<()> {
|
||||||
let chorus_request = ChorusRequest {
|
let chorus_request = ChorusRequest {
|
||||||
request: Client::new()
|
request: Client::new()
|
||||||
|
@ -48,20 +37,8 @@ impl Channel {
|
||||||
chorus_request.handle_request_as_result(user).await
|
chorus_request.handle_request_as_result(user).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modifies a channel.
|
/// Modifies a channel with the provided data.
|
||||||
///
|
/// Replaces self with the new channel object.
|
||||||
/// # 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.
|
|
||||||
pub async fn modify(
|
pub async fn modify(
|
||||||
&mut self,
|
&mut self,
|
||||||
modify_data: ChannelModifySchema,
|
modify_data: ChannelModifySchema,
|
||||||
|
@ -84,6 +61,7 @@ impl Channel {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetches recent messages from a channel.
|
||||||
pub async fn messages(
|
pub async fn messages(
|
||||||
range: GetChannelMessagesSchema,
|
range: GetChannelMessagesSchema,
|
||||||
channel_id: Snowflake,
|
channel_id: Snowflake,
|
||||||
|
|
Loading…
Reference in New Issue