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

source

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

source

pub fn fetch_self(&mut self) -> &mut Self

Fetchs the data of the currently authenticated user

Sets the UserResult enum to UserResult::User

source

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

source

pub fn edit_user(&mut self, userid: &str, changes: &str) -> &mut Self

Edits a users details

Parameters:
  • userid: &str - The userid of your user
  • changes: &str - A &str repersentation of the changes you want to make to your user
source

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

source

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 to
  • pass: &str - Your revolt password
source

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

source

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

source

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

source§

fn clone(&self) -> UserClient

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for UserClient

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more