Http

Struct Http 

Source
pub struct Http { /* private fields */ }
Expand description

An instance of a client to the REST API

Implementations§

Source§

impl Http

Source

pub async fn get_onboarding(&self) -> Result<OnboardingStatus>

Source

pub async fn complete_onboarding(&self, username: &str) -> Result

Source§

impl Http

Source

pub async fn fetch_account(&self) -> Result<Account>

Source

pub async fn create_account( email: &str, password: &str, invite: Option<&str>, captcha: Option<&str>, ) -> Result

Source

pub async fn resend_verification(email: &str, captcha: Option<&str>) -> Result

Source

pub async fn verify_email(code: &str) -> Result

Source

pub async fn send_password_reset(email: &str, captcha: Option<&str>) -> Result

Source

pub async fn password_reset(password: &str, token: &str) -> Result

Source

pub async fn change_password( &self, password: &str, current_password: &str, ) -> Result

Source

pub async fn change_email(&self, email: &str, current_password: &str) -> Result

Source

pub async fn login( email: &str, password: Option<&str>, challange: Option<&str>, friendly_name: Option<&str>, captcha: Option<&str>, ) -> Result<Session>

Source

pub async fn logout(self) -> Result

Source

pub async fn edit_session( &self, session: SessionId, friendly_name: &str, ) -> Result

Source

pub async fn delete_session(&self, session: SessionId) -> Result

Source

pub async fn fetch_sessions(&self) -> Result<Vec<SessionInfo>>

Source

pub async fn delete_all_sessions(&self, revoke_self: bool) -> Result

Source§

impl Http

Source

pub async fn fetch_user(&self, user_id: UserId) -> Result<User>

Gets an user from the api

Source

pub async fn edit_user(&self, patch: UserEditPatch) -> Result

Edits user

Source

pub async fn edit_username(&self, username: &str, password: &str) -> Result

Edits an username

Source

pub async fn fetch_user_profile(&self, user_id: UserId) -> Result<Profile>

Gets information abot an user profile

Source

pub async fn fetch_mutual_friends(&self, user_id: UserId) -> Result<Vec<UserId>>

Source§

impl Http

Source

pub async fn fetch_dm_channels(&self) -> Result<Vec<Channel>>

Gets dm channels / groups.

Source

pub async fn open_dm(&self, user_id: UserId) -> Result<DirectMessageChannel>

Opens a dm with user

Source§

impl Http

Source

pub async fn fetch_relationships(&self) -> Result<Vec<Relationship>>

Fetches relationships of the current user

Source

pub async fn fetch_relationship( &self, user_id: UserId, ) -> Result<SingleRelationshipResponse>

Fetches your relationship with the given user

Source

pub async fn send_friend_request( &self, username: &str, ) -> Result<SingleRelationshipResponse>

Sends or accepts a friend request to / from the user with given username

Source

pub async fn deny_friend_request( &self, username: &str, ) -> Result<SingleRelationshipResponse>

Denies a friend request

Source

pub async fn remove_friend( &self, username: &str, ) -> Result<SingleRelationshipResponse>

Source

pub async fn block_user( &self, user_id: UserId, ) -> Result<SingleRelationshipResponse>

Blocks an user

Source

pub async fn unblock( &self, user_id: UserId, ) -> Result<SingleRelationshipResponse>

Unblocks an user

Source§

impl Http

Source

pub async fn fetch_channel(&self, channel_id: ChannelId) -> Result<Channel>

Gets the channel given the id

Source

pub async fn edit_channel( &self, channel_id: ChannelId, name: Option<String>, description: Option<String>, icon: Option<AttachmentId>, nsfw: Option<bool>, remove: Option<ChannelField>, ) -> Result

Edits the channel given by id

Source

pub async fn close_channel(&self, channel_id: ChannelId) -> Result

Closes a channel / leaves group

Source

pub async fn create_invite( &self, channel_id: ChannelId, ) -> Result<CreateChannelInviteResponse>

Creates an invite

Source

pub async fn set_channel_role_permissions( &self, channel_id: ChannelId, role_id: RoleId, permissions: ChannelPermissions, ) -> Result

Sets role permissions

Source

pub async fn set_channel_default_role_permissions( &self, channel_id: ChannelId, permissions: ChannelPermissions, ) -> Result

Sets default permissions

Source§

impl Http

Source

pub async fn send_message( &self, channel_id: ChannelId, content: impl AsRef<str>, nonce: impl AsRef<str>, attachments: Vec<AttachmentId>, replies: Vec<ReplyData>, ) -> Result<Message>

Sends a message

Source

pub async fn fetch_messages( &self, channel: ChannelId, filter: MessageFilter, ) -> Result<FetchMessagesResult>

Fetches messages

Source

pub async fn fetch_message( &self, channel: ChannelId, message: MessageId, ) -> Result<Message>

Fetches a single message

Source

pub async fn edit_message( &self, channel: ChannelId, message: MessageId, content: &str, ) -> Result

Edits a message to contain content content

Source

pub async fn delete_message( &self, channel: ChannelId, message: MessageId, ) -> Result

Deletes a message

Source

pub async fn poll_message_changes( &self, channel: ChannelId, ids: &[MessageId], ) -> Result<PollMessageChangesResponse>

Source

pub async fn acknowledge_message( &self, channel: ChannelId, message: MessageId, ) -> Result

Source§

impl Http

Source

pub async fn create_group( &self, name: String, description: Option<String>, nonce: String, users: Option<&[UserId]>, nsfw: Option<bool>, ) -> Result<Channel>

Creates a group

Source

pub async fn fetch_group_members(&self, group: ChannelId) -> Result<Vec<User>>

Fetches group members

Source§

impl Http

Source

pub async fn fetch_server(&self, server: ServerId) -> Result<Server>

Fetches a server

Source

pub async fn edit_server( &self, server_id: ServerId, server: PartialServer, remove: ServerField, ) -> Result

Edits a server

Source

pub async fn delete_server(&self, server_id: ServerId) -> Result

Deletes a server

Source

pub async fn create_server( &self, name: String, description: Option<String>, nsfw: Option<bool>, nonce: String, ) -> Result<Server>

Creates a server

Source

pub async fn create_channel( &self, server: ServerId, kind: ServerChannelType, name: String, description: Option<String>, nonce: String, ) -> Result

Creates a channel

Source

pub async fn fetch_invites( &self, server: ServerId, ) -> Result<Vec<FetchInviteResult>>

Fetches invites in server

Source

pub async fn mark_server_as_read(&self, server: ServerId) -> Result

Marks server as read

Source§

impl Http

Source

pub async fn fetch_member( &self, server_id: ServerId, user_id: UserId, ) -> Result<Member>

Fetches member in server

Source

pub async fn edit_member( &self, server_id: ServerId, user_id: UserId, member: PartialMember, remove: MemberField, ) -> Result

Edits member in server

Source

pub async fn kick_member(&self, server_id: ServerId, user_id: UserId) -> Result

Kicks member out of server

Source

pub async fn fetch_all_members( &self, server_id: ServerId, ) -> Result<FetchMembersResult>

Fetches all members in a server

Source

pub async fn ban_user( &self, server_id: ServerId, user_id: UserId, reason: Option<&str>, ) -> Result

Bans an user from the server

Source

pub async fn unban_user(&self, server_id: ServerId, user_id: UserId) -> Result

Unbans an user from the server

Source

pub async fn fetch_bans(&self, server_id: ServerId) -> Result<FetchBansResult>

Fetches all the users who are banned and the reasons associated with their bans if available

Source§

impl Http

Source

pub async fn set_role_permissions( &self, server: ServerId, role: RoleId, permissions: PermissionTuple, ) -> Result

Source

pub async fn set_default_role_permissions( &self, server: ServerId, permissions: PermissionTuple, ) -> Result

Source

pub async fn create_role( &self, server: ServerId, name: &str, ) -> Result<RoleIdAndPermissions>

Source

pub async fn delete_role(&self, server: ServerId, role: RoleId) -> Result

Source§

impl Http

Source

pub async fn create_bot(&self, name: &str) -> Result<Bot>

Source

pub async fn fetch_owned_bots(&self) -> Result<FetchOwnedBotsResponse>

Source

pub async fn fetch_bot(&self, bot: UserId) -> Result<FetchBotResponse>

Source

pub async fn edit_bot( &self, bot: UserId, name: Option<&str>, public: Option<bool>, interactions_url: Option<&str>, remove: Option<BotField>, ) -> Result

Source

pub async fn delete_bot(&self, bot: UserId) -> Result

Source

pub async fn fetch_public_bot(&self, bot: UserId) -> Result<PublicBot>

Source

pub async fn invite_bot(&self, bot: UserId, target: InviteBotTarget) -> Result

Source§

impl Http

Source

pub async fn fetch_invite(&self, invite: &str) -> Result<RetrievedInvite>

Source

pub async fn join_invite(&self, invite: &str) -> Result<JoinInviteResponse>

Source

pub async fn delete_invite(&self, invite: &str) -> Result

Source§

impl Http

Source

pub async fn new<'auth>( auth: impl Into<HttpAuthentication<'auth>>, ) -> Result<Self>

Creates a new client from the authentication

Source

pub async fn new_with_url<'auth>( auth: impl Into<HttpAuthentication<'auth>>, api_root: &str, ) -> Result<Self>

Creates a new client from the authentication and url.

Use this if using a self hosted instance of revolt, otherwise use Self::new.

Source

pub fn get_ws_url(&self) -> &str

Gets the websocket url

Source

pub async fn get_self_id(&self) -> Result<UserId>

Source

pub async fn upload_autumn( &self, tag: AttachmentTag, name: String, bytes: Vec<u8>, ) -> Result<AttachmentId>

Uploads a file to autumn, returning the AttachmentId

Auto Trait Implementations§

§

impl Freeze for Http

§

impl !RefUnwindSafe for Http

§

impl Send for Http

§

impl Sync for Http

§

impl Unpin for Http

§

impl !UnwindSafe for Http

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,