ClientApi

Trait ClientApi 

Source
pub trait ClientApi: Sync {
    type Error: ClientApiError;

Show 43 methods // Required method fn send_raw( &self, command: String, ) -> impl Future<Output = Result<JsonObject, Self::Error>> + Send; // Provided methods fn api_create_my_address( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<UserContactLinkCreatedResponse>, Self::Error>> + Send { ... } fn api_delete_my_address( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<UserContactLinkDeletedResponse>, Self::Error>> + Send { ... } fn api_show_my_address( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<UserContactLinkResponse>, Self::Error>> + Send { ... } fn api_set_profile_address( &self, command: ApiSetProfileAddress, ) -> impl Future<Output = Result<Arc<UserProfileUpdatedResponse>, Self::Error>> + Send { ... } fn api_set_address_settings( &self, user_id: i64, settings: AddressSettings, ) -> impl Future<Output = Result<Arc<UserContactLinkUpdatedResponse>, Self::Error>> + Send { ... } fn api_send_messages( &self, command: ApiSendMessages, ) -> impl Future<Output = Result<Arc<NewChatItemsResponse>, Self::Error>> + Send { ... } fn api_update_chat_item( &self, command: ApiUpdateChatItem, ) -> impl Future<Output = Result<ApiUpdateChatItemResponses, Self::Error>> + Send { ... } 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 { ... } fn api_delete_member_chat_item( &self, group_id: i64, chat_item_ids: Vec<i64>, ) -> impl Future<Output = Result<Arc<ChatItemsDeletedResponse>, Self::Error>> + Send { ... } fn api_chat_item_reaction( &self, command: ApiChatItemReaction, ) -> impl Future<Output = Result<Arc<ChatItemReactionResponse>, Self::Error>> + Send { ... } fn receive_file( &self, command: ReceiveFile, ) -> impl Future<Output = Result<ReceiveFileResponses, Self::Error>> + Send { ... } fn cancel_file( &self, file_id: i64, ) -> impl Future<Output = Result<CancelFileResponses, Self::Error>> + Send { ... } fn api_add_member( &self, group_id: i64, contact_id: i64, member_role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<SentGroupInvitationResponse>, Self::Error>> + Send { ... } fn api_join_group( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<UserAcceptedGroupSentResponse>, Self::Error>> + Send { ... } fn api_accept_member( &self, group_id: i64, group_member_id: i64, member_role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<MemberAcceptedResponse>, Self::Error>> + Send { ... } 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 { ... } fn api_block_members_for_all( &self, command: ApiBlockMembersForAll, ) -> impl Future<Output = Result<Arc<MembersBlockedForAllUserResponse>, Self::Error>> + Send { ... } fn api_remove_members( &self, command: ApiRemoveMembers, ) -> impl Future<Output = Result<Arc<UserDeletedMembersResponse>, Self::Error>> + Send { ... } fn api_leave_group( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<LeftMemberUserResponse>, Self::Error>> + Send { ... } fn api_list_members( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<GroupMembersResponse>, Self::Error>> + Send { ... } fn api_new_group( &self, command: ApiNewGroup, ) -> impl Future<Output = Result<Arc<GroupCreatedResponse>, Self::Error>> + Send { ... } fn api_update_group_profile( &self, group_id: i64, group_profile: GroupProfile, ) -> impl Future<Output = Result<Arc<GroupUpdatedResponse>, Self::Error>> + Send { ... } fn api_create_group_link( &self, group_id: i64, member_role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<GroupLinkCreatedResponse>, Self::Error>> + Send { ... } fn api_group_link_member_role( &self, group_id: i64, member_role: GroupMemberRole, ) -> impl Future<Output = Result<Arc<GroupLinkResponse>, Self::Error>> + Send { ... } fn api_delete_group_link( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<GroupLinkDeletedResponse>, Self::Error>> + Send { ... } fn api_get_group_link( &self, group_id: i64, ) -> impl Future<Output = Result<Arc<GroupLinkResponse>, Self::Error>> + Send { ... } fn api_add_contact( &self, command: ApiAddContact, ) -> impl Future<Output = Result<Arc<InvitationResponse>, Self::Error>> + Send { ... } fn api_connect_plan( &self, command: ApiConnectPlan, ) -> impl Future<Output = Result<Arc<ConnectionPlanResponse>, Self::Error>> + Send { ... } fn api_connect( &self, command: ApiConnect, ) -> impl Future<Output = Result<ApiConnectResponses, Self::Error>> + Send { ... } fn connect( &self, command: Connect, ) -> impl Future<Output = Result<ConnectResponses, Self::Error>> + Send { ... } fn api_accept_contact( &self, contact_req_id: i64, ) -> impl Future<Output = Result<Arc<AcceptingContactRequestResponse>, Self::Error>> + Send { ... } fn api_reject_contact( &self, contact_req_id: i64, ) -> impl Future<Output = Result<Arc<ContactRequestRejectedResponse>, Self::Error>> + Send { ... } fn api_list_contacts( &self, user_id: i64, ) -> impl Future<Output = Result<Arc<ContactsListResponse>, Self::Error>> + Send { ... } fn api_list_groups( &self, command: ApiListGroups, ) -> impl Future<Output = Result<Arc<GroupsListResponse>, Self::Error>> + Send { ... } fn api_delete_chat( &self, chat_ref: ChatRef, chat_delete_mode: ChatDeleteMode, ) -> impl Future<Output = Result<ApiDeleteChatResponses, Self::Error>> + Send { ... } fn show_active_user( &self, ) -> impl Future<Output = Result<Arc<ActiveUserResponse>, Self::Error>> + Send { ... } fn create_active_user( &self, new_user: NewUser, ) -> impl Future<Output = Result<Arc<ActiveUserResponse>, Self::Error>> + Send { ... } fn list_users( &self, ) -> impl Future<Output = Result<Arc<UsersListResponse>, Self::Error>> + Send { ... } fn api_set_active_user( &self, command: ApiSetActiveUser, ) -> impl Future<Output = Result<Arc<ActiveUserResponse>, Self::Error>> + Send { ... } fn api_delete_user( &self, command: ApiDeleteUser, ) -> impl Future<Output = Result<Arc<CmdOkResponse>, Self::Error>> + Send { ... } fn api_update_profile( &self, user_id: i64, profile: Profile, ) -> impl Future<Output = Result<ApiUpdateProfileResponses, Self::Error>> + Send { ... } fn api_set_contact_prefs( &self, contact_id: i64, preferences: Preferences, ) -> impl Future<Output = Result<Arc<ContactPrefsUpdatedResponse>, Self::Error>> + Send { ... }
}

Required Associated Types§

Required Methods§

Source

fn send_raw( &self, command: String, ) -> impl Future<Output = Result<JsonObject, Self::Error>> + Send

Provided Methods§

Source

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

§Address commands

Bots can use these commands to automatically check and create address when initialized


Create bot address.

Network usage: interactive.

Syntax:

/_address <userId>
Source

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

§Address commands

Bots can use these commands to automatically check and create address when initialized


Delete bot address.

Network usage: background.

Syntax:

/_delete_address <userId>
Source

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

§Address commands

Bots can use these commands to automatically check and create address when initialized


Get bot address and settings.

Network usage: no.

Syntax:

/_show_address <userId>
Source

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

§Address commands

Bots can use these commands to automatically check and create address when initialized


Add address to bot profile.

Network usage: interactive.

Syntax:

/_profile_address <userId> on|off
Source

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

§Address commands

Bots can use these commands to automatically check and create address when initialized


Set bot address settings.

Network usage: interactive.

Syntax:

/_address_settings <userId> <json(settings)>
Source

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

§Message commands

Commands to send, update, delete, moderate messages and set message reactions


Send messages.

Network usage: background.

Syntax:

/_send <str(sendRef)>[ live=on][ ttl=<ttl>] json <json(composedMessages)>
Source

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

§Message commands

Commands to send, update, delete, moderate messages and set message reactions


Update message.

Network usage: background.

Syntax:

/_update item <str(chatRef)> <chatItemId>[ live=on] json <json(updatedMessage)>
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

Commands to send, update, delete, moderate messages and set message reactions


Delete message.

Network usage: background.

Syntax:

/_delete item <str(chatRef)> <chatItemIds[0]>[,<chatItemIds[1]>...] broadcast|internal|internalMark
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

Commands to send, update, delete, moderate messages and set message reactions


Moderate message. Requires Moderator role (and higher than message author’s).

Network usage: background.

Syntax:

/_delete member item #<groupId> <chatItemIds[0]>[,<chatItemIds[1]>...]
Source

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

§Message commands

Commands to send, update, delete, moderate messages and set message reactions


Add/remove message reaction.

Network usage: background.

Syntax:

/_reaction <str(chatRef)> <chatItemId> on|off <json(reaction)>
Source

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

§File commands

Commands to receive and to cancel files. Files are sent as part of the message, there are no separate commands to send files.


Receive file.

Network usage: no.

Syntax:

/freceive <fileId>[ approved_relays=on][ encrypt=on|off][ inline=on|off][ <filePath>]
Source

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

§File commands

Commands to receive and to cancel files. Files are sent as part of the message, there are no separate commands to send files.


Cancel file.

Network usage: background.

Syntax:

/fcancel <fileId>
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

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Add contact to group. Requires bot to have Admin role.

Network usage: interactive.

Syntax:

/_add #<groupId> <contactId> observer|author|member|moderator|admin|owner
Source

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

§Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Join group.

Network usage: interactive.

Syntax:

/_join #<groupId>
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

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Accept group member. Requires Admin role.

Network usage: background.

Syntax:

/_accept member #<groupId> <groupMemberId> observer|author|member|moderator|admin|owner
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

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Set members role. Requires Admin role.

Network usage: background.

Syntax:

/_member role #<groupId> <groupMemberIds[0]>[,<groupMemberIds[1]>...] observer|author|member|moderator|admin|owner
Source

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

§Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Block members. Requires Moderator role.

Network usage: background.

Syntax:

/_block #<groupId> <groupMemberIds[0]>[,<groupMemberIds[1]>...] blocked=on|off
Source

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

§Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Remove members. Requires Admin role.

Network usage: background.

Syntax:

/_remove #<groupId> <groupMemberIds[0]>[,<groupMemberIds[1]>...][ messages=on]
Source

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

§Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Leave group.

Network usage: background.

Syntax:

/_leave #<groupId>
Source

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

§Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Get group members.

Network usage: no.

Syntax:

/_members #<groupId>
Source

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

§Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Create group.

Network usage: no.

Syntax:

/_group <userId>[ incognito=on] <json(groupProfile)>
Source

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

§Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.


Update group profile.

Network usage: background.

Syntax:

/_group_profile #<groupId> <json(groupProfile)>

These commands can be used by bots that manage multiple public groups


Create group link.

Network usage: interactive.

Syntax:

/_create link #<groupId> observer|author|member|moderator|admin|owner

These commands can be used by bots that manage multiple public groups


Set member role for group link.

Network usage: no.

Syntax:

/_set link role #<groupId> observer|author|member|moderator|admin|owner

These commands can be used by bots that manage multiple public groups


Delete group link.

Network usage: background.

Syntax:

/_delete link #<groupId>

These commands can be used by bots that manage multiple public groups


Get group link.

Network usage: no.

Syntax:

/_get link #<groupId>
Source

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

§Connection commands

These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.


Create 1-time invitation link.

Network usage: interactive.

Syntax:

/_connect <userId>[ incognito=on]
Source

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

§Connection commands

These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.


Determine SimpleX link type and if the bot is already connected via this link.

Network usage: interactive.

Syntax:

/_connect plan <userId> <connectionLink>
Source

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

§Connection commands

These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.


Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link

Network usage: interactive.

Syntax:

/_connect <userId>[ <str(preparedLink_)>]
Source

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

§Connection commands

These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.


Connect via SimpleX link as string in the active user profile.

Network usage: interactive.

Syntax:

/connect[ <connLink_>]
Source

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

§Connection commands

These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.


Accept contact request.

Network usage: interactive.

Syntax:

/_accept <contactReqId>
Source

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

§Connection commands

These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.


Reject contact request. The user who sent the request is not notified.

Network usage: no.

Syntax:

/_reject <contactReqId>
Source

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

§Chat commands

Commands to list and delete conversations.


Get contacts.

Network usage: no.

Syntax:

/_contacts <userId>
Source

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

§Chat commands

Commands to list and delete conversations.


Get groups.

Network usage: no.

Syntax:

/_groups <userId>[ @<contactId_>][ <search>]
Source

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

§Chat commands

Commands to list and delete conversations.


Delete chat.

Network usage: background.

Syntax:

/_delete <str(chatRef)> <str(chatDeleteMode)>
Source

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

§User profile commands

Most bots don’t need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).


Get active user profile

Network usage: no.

Syntax:

/user
Source

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

§User profile commands

Most bots don’t need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).


Create new user profile

Network usage: no.

Syntax:

/_create user <json(newUser)>
Source

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

§User profile commands

Most bots don’t need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).


Get all user profiles

Network usage: no.

Syntax:

/users
Source

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

§User profile commands

Most bots don’t need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).


Set active user profile

Network usage: no.

Syntax:

/_user <userId>[ <json(viewPwd)>]
Source

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

§User profile commands

Most bots don’t need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).


Delete user profile.

Network usage: background.

Syntax:

/_delete user <userId> del_smp=on|off[ <json(viewPwd)>]
Source

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

§User profile commands

Most bots don’t need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).


Update user profile.

Network usage: background.

Syntax:

/_profile <userId> <json(profile)>
Source

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

§User profile commands

Most bots don’t need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).


Configure chat preference overrides for the contact.

Network usage: background.

Syntax:

/_set prefs @<contactId> <json(preferences)>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§