Skip to content

Struct Community

zaun_client::Community · Struct

pub struct Community { … }

A community this client belongs to (or did: a handle outlives a leave).

pub fn dms(&self) -> Vec<Channel>

This member’s open DMs, from the cache.

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

Reloads the open DMs from the host.

The host refused or did not answer.

pub fn dm_settings(&self) -> Result<DmSettings>

This member’s DM setting.

The host refused or did not answer.

pub fn set_dms_from_bots(&self, allow: bool) -> Result<DmSettings>

Lets bots open DMs with this member (true), or not.

The host refused or did not answer.

pub fn presences(&self) -> Vec<Presence>

The presence of every member who is not offline.

pub fn set_status_text(&self, text: Option<&str>, emoji: Option<&str>, expires_at: Option<u64>) -> Result<MemberData>

Sets this member’s custom status here (text, emoji, and when the host clears it, ms); None for both text and emoji clears it. Everyone else gets a member update.

The host’s refusal (PAYLOAD_TOO_LARGE past 128 characters, BAD_REQUEST), or a connection error.

pub fn commands(&self) -> Vec<ApplicationCommand>

Every bot command in the community, as last heard (each with its bot_id).

pub fn bots(&self) -> Vec<BotCard>

The installed bots’ public cards, as last heard.

pub fn fetch_bots(&self) -> Result<Vec<BotCard>>

Asks the host for every bot’s card (owners also get each bot’s full request).

The host refused or did not answer.

pub fn bot(&self, bot: BotId) -> Result<BotCard>

Asks the host for one bot’s card.

The host refused (NOT_FOUND) or did not answer.

pub fn install_bot(&self, package: AttachmentId, grants: Option<GrantChoice>, role_position: Option<u32>) -> Result<BotCard>

Owner only: installs the .zbot package uploaded as package (an attachment not on a message). grants absent: everything the manifest asks for, within the host’s ceiling.

The host refused (not the owner, a bad package, over the ceiling) or did not answer.

pub fn update_bot(&self, bot: BotId, package: AttachmentId) -> Result<BotCard>

Owner only: updates a bot to a newer package of the same publisher.

As install_bot.

pub fn grant_bot(&self, bot: BotId, permissions: Option<Permissions>, capabilities: Option<Capabilities>) -> Result<BotCard>

Owner only: replaces a bot’s grants (approves a waiting update when it covers it).

The host refused or did not answer.

pub fn enable_bot(&self, bot: BotId) -> Result<BotCard>

Owner only: starts a disabled bot.

The host refused or did not answer.

pub fn disable_bot(&self, bot: BotId) -> Result<BotCard>

Owner only: stops a bot and hides its commands.

The host refused or did not answer.

pub fn remove_bot(&self, bot: BotId, keep_data: bool) -> Result<()>

Owner only: removes a bot, its role and commands (and its data unless keep_data).

The host refused or did not answer.

pub fn register_bot(&self, member: &Member, name: Option<&str>) -> Result<BotCard>

Owner only: marks member (a client connected over SimpleX) as an external bot.

The host refused or did not answer.

pub fn set_commands(&self, commands: Vec<ApplicationCommand>) -> Result<Vec<ApplicationCommand>>

As a bot: replaces this bot’s whole command list; answers it with the host’s ids.

The host refused (this member is not a bot, a command breaks the rules).

pub fn configure_bot<K, V, impl IntoIterator<Item = (K, Option<V>)>>(&self, bot: BotId, values: impl IntoIterator<Item = (K, Option<V>)>) -> Result<BTreeMap<String, String>>

Owner only: sets (Some) or clears (None, back to the default) the values of the settings bot’s manifest declares (its card’s config), and answers every value the owner has set, a secret one as "••••" (MASKED). The bot gets them at once. Keys are [a-z][a-z0-9_]{0,63}, values ≤ 4 KiB, ≤ 32 of each.

A malformed key or value (Error::Protocol), or the host refused: FORBIDDEN (not the owner), NOT_FOUND (no such bot), BAD_REQUEST with field config.<key> (a key the manifest does not declare). Needs zaun-host 0.4.0.

pub fn bot_config(&self, bot: BotId) -> Result<BTreeMap<String, String>>

Owner only: the values set for bot’s settings, a secret one as "••••"; a key not here uses its card’s default.

As configure_bot.

pub fn install_bot_from(&self, package: AttachmentId, grants: Option<GrantChoice>, role_position: Option<u32>, source: InstallSource) -> Result<BotCard>

Owner only: install_bot with the registry source the package was verified against: the uploaded catalog.json, its signature and, for a version not in the catalog’s latest, the uploaded history file. The host checks the source offline against its own registry keys; one that does not verify installs as direct.

As install_bot, and BAD_REQUEST for a source that repeats an attachment or has a blank signature.

pub fn update_bot_from(&self, bot: BotId, package: AttachmentId, source: InstallSource) -> Result<BotCard>

Owner only: update_bot with the registry source the new package was verified against, as for install_bot_from.

As install_bot_from.

pub const fn id(&self) -> CommunityId

Its id.

pub fn data(&self) -> Option<CommunityData>

A copy of the cache: the whole community as plain data, or None when this client does not belong to it (any more).

pub fn name(&self) -> String

Its name, from the descriptor the host’s welcome proved (empty before).

pub fn description(&self) -> Option<String>

Its description, from the same descriptor.

pub fn is_owner(&self) -> bool

Whether this client owns it.

pub fn me(&self) -> Option<Member>

This client as a member of it.

pub fn channels(&self) -> Vec<Channel>

Its channels and categories this member can see, in order.

pub fn channel_by_name(&self, name: &str) -> Option<Channel>

The first channel named name (names are not unique).

pub fn channel(&self, id: ChannelId) -> Channel

The channel id, known to the cache or not.

pub fn roles(&self) -> Vec<Role>

Its roles, highest first.

pub fn role_by_name(&self, name: &str) -> Option<Role>

The first role named name.

pub fn role(&self, id: RoleId) -> Role

The role id, known to the cache or not.

pub fn members(&self) -> Vec<Member>

The members the cache has heard of; fetch_members loads them all.

pub fn member(&self, id: MemberId) -> Member

The member id, known to the cache or not.

pub fn fetch_members(&self) -> Result<Vec<Member>>

Loads every member into the cache.

The host refused or did not answer.

pub fn create_channel(&self, name: &str, kind: ChannelKind) -> Result<Channel>

Makes a channel of kind named name.

The host refused (no MANAGE_CHANNELS) or did not answer.

pub fn create_channel_in(&self, parent: &Channel, name: &str, kind: ChannelKind) -> Result<Channel>

Makes a channel of kind named name inside the category parent.

As create_channel.

pub fn create_role(&self, name: &str, permissions: Permissions) -> Result<Role>

Makes a role named name with permissions.

The host refused (no MANAGE_ROLES, or permissions this member lacks) or did not answer.

pub fn create_invite(&self, max_uses: u32, expires_in: Option<Duration>) -> Result<String>

Makes an invitation link for max_uses joins (0: no limit), expiring after expires_in if given. The link is a secret: give it only to who should join.

The host refused or did not answer.

pub fn leave(&self) -> Result<()>

Leaves the community (the owner cannot). Once the host accepts, it is forgotten here: its state and member key leave the store, Event::CommunityDelete follows with RemovalReason::Left, and a later Client::join of it starts afresh.

The host refused or did not answer.

pub fn hand_off(&self, host_address: &str, host_key: PublicKey) -> Result<HandOff>

As the owner, hands the community to the host at host_address whose key is host_key; see HandOff.

This client does not hold the root key, the host refused, or no answer came.

pub fn follow(&self, host_address: &str, host_key: PublicKey) -> Result<HostId>

Follows the community to the host the owner named, when no descriptor update arrived.

The new host refused this member, or a timeout.

pub fn voice_channels(&self) -> Vec<Channel>

This member’s voice channels.

Clone, Debug, Display, PartialEq

Full rustdoc page