Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Available on crate feature websocket only.
Expand description

A high level SimpleX-Chat client which provides typed API methods with automatic command serialization and response deserialization.

Implementations§

Source§

impl Client

Source

pub fn version( &self, ) -> impl Future<Output = Result<SimplexVersion, VersionError>>

Source

pub fn disconnect(self) -> impl Future<Output = ()>

Initiates a graceful shutdown for the underlying web socket connection. See simploxide_ws_core::RawClient::disconnect for details.

Trait Implementations§

Source§

impl ClientApi for Client

Source§

type ResponseShape<'de, T> = WebSocketResponseShape<T> where T: 'de + Deserialize<'de>

Source§

type Error = ClientError

Source§

async fn send_raw(&self, command: String) -> Result<String, Self::Error>

Source§

fn send<C, R>( &self, cmd: C, ) -> impl Future<Output = Result<R, Self::Error>> + Send
where C: Send + CommandSyntax, R: for<'de> Deserialize<'de>,

Source§

fn api_create_my_address( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<UserContactLinkCreatedResponse>, Self::Error>> + Send

Address commands Read more
Source§

fn api_delete_my_address( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<UserContactLinkDeletedResponse>, Self::Error>> + Send

Address commands Read more
Source§

fn api_show_my_address( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<UserContactLinkResponse>, Self::Error>> + Send

Address commands Read more
Source§

fn api_set_profile_address( &self, command: ApiSetProfileAddress, ) -> impl Future<Output = Result<Arc<UserProfileUpdatedResponse>, Self::Error>> + Send

Address commands Read more
Source§

fn api_set_address_settings( &self, user_id: i64, settings: AddressSettings, ) -> impl Future<Output = Result<Arc<UserContactLinkUpdatedResponse>, Self::Error>> + Send

Address commands Read more
Source§

fn api_send_messages( &self, command: ApiSendMessages, ) -> impl Future<Output = Result<Arc<NewChatItemsResponse>, Self::Error>> + Send

Message commands Read more
Source§

fn api_update_chat_item( &self, command: ApiUpdateChatItem, ) -> impl Future<Output = Result<ApiUpdateChatItemResponse, Self::Error>> + Send

Message commands Read more
Source§

fn api_delete_chat_item( &self, chat_ref: ChatRef, chat_item_ids: Vec<i64>, delete_mode: CIDeleteMode, ) -> impl Future<Output = Result<Arc<ChatItemsDeletedResponse>, Self::Error>> + Send

Message commands Read more
Source§

fn api_delete_member_chat_item( &self, group_id: i64, chat_item_ids: Vec<i64>, ) -> impl Future<Output = Result<Arc<ChatItemsDeletedResponse>, Self::Error>> + Send

Message commands Read more
Source§

fn api_chat_item_reaction( &self, command: ApiChatItemReaction, ) -> impl Future<Output = Result<Arc<ChatItemReactionResponse>, Self::Error>> + Send

Message commands Read more
Source§

fn receive_file( &self, command: ReceiveFile, ) -> impl Future<Output = Result<ReceiveFileResponse, Self::Error>> + Send

File commands Read more
Source§

fn cancel_file( &self, file_id: i64, ) -> impl Future<Output = Result<CancelFileResponse, Self::Error>> + Send

File commands Read more
Source§

fn api_add_member( &self, group_id: i64, contact_id: i64, member_role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<SentGroupInvitationResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_join_group( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<UserAcceptedGroupSentResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_accept_member( &self, group_id: i64, group_member_id: i64, member_role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<MemberAcceptedResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_members_role( &self, group_id: i64, group_member_ids: Vec<i64>, member_role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<MembersRoleUserResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_block_members_for_all( &self, command: ApiBlockMembersForAll, ) -> impl Future<Output = Result<Arc<MembersBlockedForAllUserResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_remove_members( &self, command: ApiRemoveMembers, ) -> impl Future<Output = Result<Arc<UserDeletedMembersResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_leave_group( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<LeftMemberUserResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_list_members( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<GroupMembersResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_new_group( &self, command: ApiNewGroup, ) -> impl Future<Output = Result<Arc<GroupCreatedResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_new_public_group( &self, command: ApiNewPublicGroup, ) -> impl Future<Output = Result<ApiNewPublicGroupResponse, Self::Error>> + Send

Group commands Read more
Source§

fn api_get_group_relays( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<GroupRelaysResponse>, Self::Error>> + Send

Group commands Read more
Source§

fn api_add_group_relays( &self, group_id: i64, relay_ids: Vec<i64>, ) -> impl Future<Output = Result<ApiAddGroupRelaysResponse, Self::Error>> + Send

Group commands Read more
Source§

fn api_update_group_profile( &self, group_id: i64, group_profile: GroupProfile, ) -> impl Future<Output = Result<Arc<GroupUpdatedResponse>, Self::Error>> + Send

Group commands Read more
Group link commands Read more
Group link commands Read more
Group link commands Read more
Group link commands Read more
Source§

fn api_add_contact( &self, command: ApiAddContact, ) -> impl Future<Output = Result<Arc<InvitationResponse>, Self::Error>> + Send

Connection commands Read more
Source§

fn api_connect_plan( &self, command: ApiConnectPlan, ) -> impl Future<Output = Result<Arc<ConnectionPlanResponse>, Self::Error>> + Send

Connection commands Read more
Source§

fn api_connect( &self, command: ApiConnect, ) -> impl Future<Output = Result<ApiConnectResponse, Self::Error>> + Send

Connection commands Read more
Source§

fn connect( &self, command: Connect, ) -> impl Future<Output = Result<ConnectResponse, Self::Error>> + Send

Connection commands Read more
Source§

fn api_accept_contact( &self, contact_req_id: i64, ) -> impl Future<Output = Result<Arc<AcceptingContactRequestResponse>, Self::Error>> + Send

Connection commands Read more
Source§

fn api_reject_contact( &self, contact_req_id: i64, ) -> impl Future<Output = Result<Arc<ContactRequestRejectedResponse>, Self::Error>> + Send

Connection commands Read more
Source§

fn api_list_contacts( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<ContactsListResponse>, Self::Error>> + Send

Chat commands Read more
Source§

fn api_list_groups( &self, command: ApiListGroups, ) -> impl Future<Output = Result<Arc<GroupsListResponse>, Self::Error>> + Send

Chat commands Read more
Source§

fn api_get_chats( &self, command: ApiGetChats, ) -> impl Future<Output = Result<Arc<ApiChatsResponse>, Self::Error>> + Send

Chat commands Read more
Source§

fn api_delete_chat( &self, chat_ref: ChatRef, chat_delete_mode: ChatDeleteMode, ) -> impl Future<Output = Result<ApiDeleteChatResponse, Self::Error>> + Send

Chat commands Read more
Source§

fn api_set_group_custom_data( &self, command: ApiSetGroupCustomData, ) -> impl Future<Output = Result<Arc<CmdOkResponse>, Self::Error>> + Send

Chat commands Read more
Source§

fn api_set_contact_custom_data( &self, command: ApiSetContactCustomData, ) -> impl Future<Output = Result<Arc<CmdOkResponse>, Self::Error>> + Send

Chat commands Read more
Source§

fn api_set_user_auto_accept_member_contacts( &self, command: ApiSetUserAutoAcceptMemberContacts, ) -> impl Future<Output = Result<Arc<CmdOkResponse>, Self::Error>> + Send

Chat commands Read more
Source§

fn show_active_user( &self, ) -> impl Future<Output = Result<Arc<ActiveUserResponse>, Self::Error>> + Send

User profile commands Read more
Source§

fn create_active_user( &self, new_user: NewUser, ) -> impl Future<Output = Result<Arc<ActiveUserResponse>, Self::Error>> + Send

User profile commands Read more
Source§

fn list_users( &self, ) -> impl Future<Output = Result<Arc<UsersListResponse>, Self::Error>> + Send

User profile commands Read more
Source§

fn api_set_active_user( &self, command: ApiSetActiveUser, ) -> impl Future<Output = Result<Arc<ActiveUserResponse>, Self::Error>> + Send

User profile commands Read more
Source§

fn api_delete_user( &self, command: ApiDeleteUser, ) -> impl Future<Output = Result<Arc<CmdOkResponse>, Self::Error>> + Send

User profile commands Read more
Source§

fn api_update_profile( &self, user_id: i64, profile: Profile, ) -> impl Future<Output = Result<ApiUpdateProfileResponse, Self::Error>> + Send

User profile commands Read more
Source§

fn api_set_contact_prefs( &self, contact_id: i64, preferences: Preferences, ) -> impl Future<Output = Result<Arc<ContactPrefsUpdatedResponse>, Self::Error>> + Send

User profile commands Read more
Source§

fn start_chat( &self, command: StartChat, ) -> impl Future<Output = Result<StartChatResponse, Self::Error>> + Send

Chat management Read more
Source§

fn api_stop_chat( &self, ) -> impl Future<Output = Result<Arc<ChatStoppedResponse>, Self::Error>> + Send

Chat management Read more
Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl From<RawClient> for Client

Source§

fn from(inner: RawClient) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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<C> ClientApiExt for C
where C: ClientApi,

Source§

async fn users(&self) -> Result<Vec<UserInfo>, <C as ClientApi>::Error>

Source§

async fn contacts<UID>( &self, user_id: UID, ) -> Result<Vec<Contact>, <C as ClientApi>::Error>
where UID: Into<UserId>,

Source§

async fn groups<UID>( &self, user_id: UID, ) -> Result<Vec<GroupInfo>, <C as ClientApi>::Error>
where UID: Into<UserId>,

Source§

async fn new_user( &self, user: NewUser, ) -> Result<Arc<ActiveUserResponse>, <C as ClientApi>::Error>

Like ClientApi::create_active_user but ensures that user is created even if the name contains disallowed in SimpleX-Chat UTF-8 characters. The NewUser struct gets cloned when performing the original request
Source§

fn accept_contact<CRID>( &self, contact_request_id: CRID, ) -> impl Future<Output = Result<Arc<AcceptingContactRequestResponse>, <C as ClientApi>::Error>>
where CRID: Into<ContactRequestId>,

Source§

fn reject_contact<CRID>( &self, contact_request_id: CRID, ) -> impl Future<Output = Result<Arc<ContactRequestRejectedResponse>, <C as ClientApi>::Error>>
where CRID: Into<ContactRequestId>,

Source§

fn send_message<CID, M>( &self, cid: CID, msg: M, ) -> MessageBuilder<'_, C, <M as MessageLike>::Kind>
where CID: Into<ChatId>, M: MessageLike,

Returns a powerful awaitable MessageBuilder type. Check its docs to learn how to build any message kind ergonomically
Source§

fn multicast_message<I, M>( &self, chat_ids: I, msg: M, ) -> MulticastBuilder<'_, I, C, <M as MessageLike>::Kind>
where I: IntoIterator<Item = ChatId>, M: MessageLike,

Deliver the same message to multiple recepients
Source§

fn update_message<CID, MID>( &self, chat_id: CID, message_id: MID, new_content: MsgContent, ) -> impl Future<Output = Result<ApiUpdateChatItemResponse, <C as ClientApi>::Error>>
where CID: Into<ChatId>, MID: Into<MessageId>,

Source§

fn batch_delete_messages<CID, I>( &self, chat_id: CID, message_ids: I, mode: CIDeleteMode, ) -> impl Future<Output = Result<Arc<ChatItemsDeletedResponse>, <C as ClientApi>::Error>>
where CID: Into<ChatId>, I: IntoIterator<Item = MessageId>,

Source§

fn batch_message_reactions<CID, MID, I>( &self, chat_id: CID, message_id: MID, reactions: I, ) -> impl Future<Output = Vec<Result<Arc<ChatItemReactionResponse>, <C as ClientApi>::Error>>>
where CID: Into<ChatId>, MID: Into<MessageId>, I: IntoIterator<Item = Reaction>,

Source§

fn accept_file<FID>(&self, file_id: FID) -> AcceptFileBuilder<'_, C>
where FID: Into<FileId>,

Source§

fn reject_file<FID>( &self, file_id: FID, ) -> impl Future<Output = Result<CancelFileResponse, <C as ClientApi>::Error>>
where FID: Into<FileId>,

Source§

fn initiate_connection( &self, link: impl Into<String>, ) -> impl Future<Output = Result<UndocumentedResponse<ConnectResponse>, <C as ClientApi>::Error>>

Source§

fn delete_chat<CID>( &self, chat_id: CID, mode: DeleteMode, ) -> impl Future<Output = Result<ApiDeleteChatResponse, <C as ClientApi>::Error>>
where CID: Into<ChatId>,

Source§

fn add_member<GID, CID>( &self, group_id: GID, contact_id: CID, role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<SentGroupInvitationResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, CID: Into<ContactId>,

Source§

fn join_group<GID>( &self, group_id: GID, ) -> impl Future<Output = Result<Arc<UserAcceptedGroupSentResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>,

Source§

fn accept_member<GID, MID>( &self, group_id: GID, member_id: MID, role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<MemberAcceptedResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, MID: Into<MemberId>,

Source§

fn set_members_role<GID, I>( &self, group_id: GID, member_ids: I, role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<MembersRoleUserResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, I: IntoIterator<Item = MemberId>,

Source§

fn block_members_for_all<GID, I>( &self, group_id: GID, member_ids: I, ) -> impl Future<Output = Result<Arc<MembersBlockedForAllUserResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, I: IntoIterator<Item = MemberId>,

Source§

fn unblock_members_for_all<GID, I>( &self, group_id: GID, member_ids: I, ) -> impl Future<Output = Result<Arc<MembersBlockedForAllUserResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, I: IntoIterator<Item = MemberId>,

Source§

fn remove_members<GID, I>( &self, group_id: GID, member_ids: I, ) -> impl Future<Output = Result<Arc<UserDeletedMembersResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, I: IntoIterator<Item = MemberId>,

Source§

fn remove_members_with_messages<GID, I>( &self, group_id: GID, member_ids: I, ) -> impl Future<Output = Result<Arc<UserDeletedMembersResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, I: IntoIterator<Item = MemberId>,

Source§

fn leave_group<GID>( &self, group_id: GID, ) -> impl Future<Output = Result<Arc<LeftMemberUserResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>,

Source§

async fn list_members<GID>( &self, group_id: GID, ) -> Result<Vec<GroupMember>, <C as ClientApi>::Error>
where GID: Into<GroupId>,

Source§

fn moderate_messages<GID, I>( &self, group_id: GID, message_ids: I, ) -> impl Future<Output = Result<Arc<ChatItemsDeletedResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>, I: IntoIterator<Item = MessageId>,

Source§

fn update_group_profile<GID>( &self, group_id: GID, profile: GroupProfile, ) -> impl Future<Output = Result<Arc<GroupUpdatedResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>,

Source§

fn set_group_custom_data<GID>( &self, group_id: GID, data: Option<Value>, ) -> impl Future<Output = Result<Arc<CmdOkResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>,

Source§

fn set_contact_custom_data<CID>( &self, contact_id: CID, data: Option<Value>, ) -> impl Future<Output = Result<Arc<CmdOkResponse>, <C as ClientApi>::Error>>
where CID: Into<ContactId>,

Source§

fn get_group_relays<GID>( &self, group_id: GID, ) -> impl Future<Output = Result<Arc<GroupRelaysResponse>, <C as ClientApi>::Error>>
where GID: Into<GroupId>,

Source§

fn add_group_relays<GID, I>( &self, group_id: GID, relay_ids: I, ) -> impl Future<Output = Result<ApiAddGroupRelaysResponse, <C as ClientApi>::Error>>
where GID: Into<GroupId>, I: IntoIterator<Item = RelayId>,

Source§

fn delete_message<CID: Into<ChatId>, MID: Into<MessageId>>( &self, chat_id: CID, message_id: MID, mode: CIDeleteMode, ) -> impl Future<Output = DeleteMessageResponse<Self>>

Source§

fn update_message_reaction<CID: Into<ChatId>, MID: Into<MessageId>>( &self, chat_id: CID, message_id: MID, reaction: Reaction, ) -> impl Future<Output = UpdateMessageReactionsResponse<Self>>

Source§

fn set_member_role<GID: Into<GroupId>, MID: Into<MemberId>>( &self, group_id: GID, member_id: MID, role: GroupMemberRole, ) -> impl Future<Output = SetMembersRoleResponse<Self>>

Source§

fn block_member_for_all<GID: Into<GroupId>, MID: Into<MemberId>>( &self, group_id: GID, member_id: MID, ) -> impl Future<Output = BlockMembersResponse<Self>>

Source§

fn unblock_member_for_all<GID: Into<GroupId>, MID: Into<MemberId>>( &self, group_id: GID, member_id: MID, ) -> impl Future<Output = BlockMembersResponse<Self>>

Source§

fn remove_member<GID: Into<GroupId>, MID: Into<MemberId>>( &self, group_id: GID, member_id: MID, ) -> impl Future<Output = RemoveMembersResponse<Self>>

Source§

fn remove_member_with_messages<GID: Into<GroupId>, MID: Into<MemberId>>( &self, group_id: GID, member_id: MID, ) -> impl Future<Output = RemoveMembersResponse<Self>>

Source§

fn moderate_message<GID: Into<GroupId>, MID: Into<MessageId>>( &self, group_id: GID, message_id: MID, ) -> impl Future<Output = DeleteMessageResponse<Self>>

Source§

fn add_group_relay<GID: Into<GroupId>, RID: Into<RelayId>>( &self, group_id: GID, relay_id: RID, ) -> impl Future<Output = AddGroupRelaysResponse<Self>>

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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