Struct volt::user::UserClient
source · pub struct UserClient { /* private fields */ }Expand description
The client to acsses user information
Returns:
The desired information as the inbuild UserResult enum type
Semantic Notes:
To correctly run without errors you must call UserClient::new() with your authentication token as the paramenter, then any of the funcions other then .run() last you must call .run()
What will go wrong:
- Only
::new()will print out the parameters passed to the enum without refreshing it - Taking out
.run()will again only print the parameters passed to the enum but it will refresh it to defult empty values - Calling
.run() after::new()` will panic! with an unwrap error - Excluding
::new()wont let you run due to missing parameters (auth)
Implementations§
source§impl UserClient
impl UserClient
sourcepub fn new(auth: String) -> UserClient
pub fn new(auth: String) -> UserClient
Creates a new UserClient object
What this function does is initialize all of the values for the client to use
This function must be directly called after UserClient (ex: UserClient::new(auth))
Parameters
auth: String - The revolt authentication token of the user
sourcepub fn fetch_self(&mut self) -> &mut Self
pub fn fetch_self(&mut self) -> &mut Self
Fetchs the data of the currently authenticated user
Sets the UserResult enum to UserResult::User
sourcepub fn fetch_user(&mut self, userid: &str) -> &mut Self
pub fn fetch_user(&mut self, userid: &str) -> &mut Self
Fetchs a user’s data
Sets the UserResult enum to UserResult::User
Parameters:
userid: &str - The userid of the user you want data for on revolt
sourcepub fn edit_user(&mut self, userid: &str, changes: &str) -> &mut Self
pub fn edit_user(&mut self, userid: &str, changes: &str) -> &mut Self
Edits a users details
Parameters:
userid: &str- The userid of your userchanges: &str- A &str repersentation of the changes you want to make to your user
sourcepub fn fetch_user_flags(&mut self, userid: &str) -> &mut Self
pub fn fetch_user_flags(&mut self, userid: &str) -> &mut Self
Fetchs the flags of a user
Flags are information about the users account status on revolt
- 1: Suspended
- 2: Deleted
- 4: Banned
Sets the UserResult enum to UserResult::UsersFlags
Parameters:
userid: &str - The userid of the user you want data for on revolt
sourcepub fn change_username(&mut self, username: &str, pass: &str) -> &mut Self
pub fn change_username(&mut self, username: &str, pass: &str) -> &mut Self
Changes a users username
Parameters:
username: &str- The username you want to change topass: &str- Your revolt password
sourcepub fn fetch_default_avatar(&mut self, userid: &str) -> &mut Self
pub fn fetch_default_avatar(&mut self, userid: &str) -> &mut Self
Returns the binary data of a persons avatar
This function in pair with ‘avatar’ in UserResult will return a string that you will have to parse to form an image
Parameters:
userid: &str - The id of the user that you want the avatar of
sourcepub fn fetch_user_profile(&mut self, userid: &str) -> &mut Self
pub fn fetch_user_profile(&mut self, userid: &str) -> &mut Self
fetchs the profile data of a user
Parameters:
userid: &str - The id of the user that you want to fetch the profile of
sourcepub fn run(&mut self) -> UserResult
pub fn run(&mut self) -> UserResult
Runs the client
This function makes the request, applies rate limits, and caches/retrives values from the cache
Note: This funtion is required to come immediatly after any one of the other funtions
Retruns:
This function returns a UserResult enum that can be printed out or used to get more specific data from the json data provided
Trait Implementations§
source§impl Clone for UserClient
impl Clone for UserClient
source§fn clone(&self) -> UserClient
fn clone(&self) -> UserClient
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more