Skip to main content

Community

Struct Community 

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

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

Implementations§

Source§

impl Community

Source

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

This member’s open DMs, from the cache.

Source

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

Reloads the open DMs from the host.

§Errors

The host refused or did not answer.

Source

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

This member’s DM setting.

§Errors

The host refused or did not answer.

Source

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

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

§Errors

The host refused or did not answer.

Source§

impl Community

Source

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

The presence of every member who is not offline.

Source

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.

§Errors

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

Source§

impl Community

Source

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

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

Source

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

The installed bots’ public cards, as last heard.

Source

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

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

§Errors

The host refused or did not answer.

Source

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

Asks the host for one bot’s card.

§Errors

The host refused (NOT_FOUND) or did not answer.

Source

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.

§Errors

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

Source

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

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

§Errors

As install_bot.

Source

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

§Errors

The host refused or did not answer.

Source

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

Owner only: starts a disabled bot.

§Errors

The host refused or did not answer.

Source

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

Owner only: stops a bot and hides its commands.

§Errors

The host refused or did not answer.

Source

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

§Errors

The host refused or did not answer.

Source

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.

§Errors

The host refused or did not answer.

Source

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.

§Errors

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

Source§

impl Community

Source

pub fn configure_bot<K, V>( &self, bot: BotId, values: impl IntoIterator<Item = (K, Option<V>)>, ) -> Result<BTreeMap<String, String>>
where K: Into<String>, V: Into<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.

§Errors

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.

Source

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.

§Errors

As configure_bot.

Source§

impl Community

Source

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.

§Errors

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

Source

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.

§Errors

As install_bot_from.

Source§

impl Community

Source

pub const fn id(&self) -> CommunityId

Its id.

Source

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

Source

pub fn name(&self) -> String

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

Source

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

Its description, from the same descriptor.

Source

pub fn is_owner(&self) -> bool

Whether this client owns it.

Source

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

This client as a member of it.

Source

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

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

Source

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

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

Source

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

The channel id, known to the cache or not.

Source

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

Its roles, highest first.

Source

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

The first role named name.

Source

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

The role id, known to the cache or not.

Source

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

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

Source

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

The member id, known to the cache or not.

Source

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

Loads every member into the cache.

§Errors

The host refused or did not answer.

Source

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

Makes a channel of kind named name.

§Errors

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

Source

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.

§Errors

As create_channel.

Source

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

Makes a role named name with permissions.

§Errors

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

Source

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.

§Errors

The host refused or did not answer.

Source

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.

§Errors

The host refused or did not answer.

Source

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.

§Errors

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

Source

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.

§Errors

The new host refused this member, or a timeout.

Source

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

This member’s voice channels.

Trait Implementations§

Source§

impl Clone for Community

Source§

fn clone(&self) -> Community

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 Debug for Community

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Community

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Community

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> CryptoSafe for T
where T: Send + Sync + Debug,

§

impl<T> CryptoSafe for T

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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