# zaun-client 0.6.0

> API reference of the zaun_client crate, generated from rustdoc.

Generated from rustdoc for `zaun_client` 0.6.0. [Browse the full rustdoc HTML](/docs/api/rust/zaun-client/zaun_client/index.html).

A Zaun community client over SimpleX: join, post, moderate and cache communities.

`Client` runs one SimpleX client and keeps a post-quantum connection per community to the
community's host (`zaun-host`). It verifies the host, registers a member key, and keeps a
local cache of each community (channels, roles, members) up to date from the host's events.
In the spirit of discord.js, what it reports are objects that act for themselves:
`Community`, `Channel`, `Message`, `Member`, `Role`, `Attachment`.
`Client::command` sends any command the objects do not wrap.

```rust
use zaun_client::{Client, Event};

let client = Client::builder("./bot").name("Ping bot").key("store passphrase").start()?;
let community = client.join("zaun://join/…", "Ping bot")?;
let general = community.channel_by_name("general").expect("a general channel");
general.send("hello")?;
for event in client.events() {
    match event {
        Event::MessageCreate(message) if message.content() == "!ping" => {
            message.reply("pong")?;
        }
        Event::MemberAdd(member) => println!("welcome, {member}"),
        _ => {}
    }
}
```

Messages carry rich embeds as discord.js's do: build one with `EmbedBuilder` and post it
with `MessageOptions`. Its pictures are files uploaded as the message's attachments, never
remote URLs, so no reader's client fetches anything from a third party.

Voice channels join like discord.js's: `channel.join()?` gives a `VoiceSession`, and an
`AudioPlayer` subscribed to it plays files for a music bot.

The host is the authority: the cache and `Member::can` are a local view that lets an
application hide what a member cannot do, and the host still decides.

## Constants

| Item | Summary |
|---|---|
| [`mention::EVERYONE`](/docs/reference/rust/zaun-client/constant-mention-everyone/) | The text that shows `@everyone`. |
| [`TEXT_BUDGET`](/docs/reference/rust/zaun-client/constant-text_budget/) | The largest frame text, in bytes as written inside the JSON string that carries it (`framing::escaped_len`: every `"` or `\` counts twice), that one message always carries, uncompr |
| [`TYPING_SHOWN_MS`](/docs/reference/rust/zaun-client/constant-typing_shown_ms/) | How long one typing signal shows: the host repeats it at most every 3 s while typing goes on, so two missed repeats end it. |

## Enums

| Item | Summary |
|---|---|
| [`AudioPlayerEvent`](/docs/reference/rust/zaun-client/enum-audioplayerevent/) | What a player tells the application. |
| [`AudioPlayerStatus`](/docs/reference/rust/zaun-client/enum-audioplayerstatus/) | What a player is doing. |
| [`ui::EntityKind`](/docs/reference/rust/zaun-client/enum-ui-entitykind/) | What an entity select offers. |
| [`Error`](/docs/reference/rust/zaun-client/enum-error/) | A `zaun-client` failure. |
| [`Event`](/docs/reference/rust/zaun-client/enum-event/) | One thing that happened. |
| [`Picture`](/docs/reference/rust/zaun-client/enum-picture/) | Where an embed's picture (or a message's file) comes from. Pictures are never remote URLs: a file is uploaded as one of the message's attachments, so no reader's client ever fetche |
| [`TypingNow`](/docs/reference/rust/zaun-client/enum-typingnow/) | Who else is typing in a channel, as the host last said. This client is never among them. |
| [`VoiceEvent`](/docs/reference/rust/zaun-client/enum-voiceevent/) | What happens in a voice session. |

## Functions

| Item | Summary |
|---|---|
| [`presence::activity`](/docs/reference/rust/zaun-client/function-presence-activity/) | An activity of `kind` named `name`, for `Client::set_presence`. Set `details`, `state`, `started_at`, `url` (streaming) or `emoji` (custom) on it as needed. |
| [`files::guess_mime`](/docs/reference/rust/zaun-client/function-files-guess_mime/) | A media type from a file name's extension; `application/octet-stream` otherwise. |
| [`registry::inspect_package`](/docs/reference/rust/zaun-client/function-registry-inspect_package/) | What a `.zbot` file says, whether its signature verifies and whether it passes the registry's package checks. |
| [`registry::key_id`](/docs/reference/rust/zaun-client/function-registry-key_id/) | The id of a base64url public key: what a bot card's `source.registry_id` is compared with. |
| [`presence::line`](/docs/reference/rust/zaun-client/function-presence-line/) | "Playing {name}", "Streaming {name}", "Listening to {name}", "Watching {name}", "Competing in {name}", or `{emoji} {name}` for a custom one. |
| [`files::measure`](/docs/reference/rust/zaun-client/function-files-measure/) | The size and SHA3-256 of the file at `path`. |
| [`mention::member`](/docs/reference/rust/zaun-client/function-mention-member/) | The text that shows a member mention, `<@id>` (discord.js `userMention`). It only shows where the mention is: the message's mentions list is what notifies. |
| [`mention::parse`](/docs/reference/rust/zaun-client/function-mention-parse/) | The mentions `content` shows: `<@id>` (and Discord's `<@!id>`) for members, `<@&id>` for roles, `@everyone`. Each id once, in order, at most 50 members and 20 roles; malformed ids  |
| [`mention::role`](/docs/reference/rust/zaun-client/function-mention-role/) | The text that shows a role mention, `<@&id>` (discord.js `roleMention`). |
| [`files::safe_name`](/docs/reference/rust/zaun-client/function-files-safe_name/) | A name for `name` that is safe as one path component: no separators, no control characters, no leading dots; `attachment` when nothing is left. |
| [`registry::verify_catalog`](/docs/reference/rust/zaun-client/function-registry-verify_catalog/) | Verifies `catalog.json` bytes and the text of `catalog.json.sig` against the key of `pinned` (base64url public keys) that the catalog names, at Unix time `now` (seconds), after `se |
| [`registry::verify_history`](/docs/reference/rust/zaun-client/function-registry-verify_history/) | Verifies the catalog as `verify_catalog` does (no stored serial), then `history/<app_id>.json` against the hash the verified catalog lists for it. |

## Structs

| Item | Summary |
|---|---|
| [`ui::ActionRow`](/docs/reference/rust/zaun-client/struct-ui-actionrow/) | A row of up to five buttons, or one select. |
| [`Attachment`](/docs/reference/rust/zaun-client/struct-attachment/) | A file on a message. |
| [`AudioPlayer`](/docs/reference/rust/zaun-client/struct-audioplayer/) | Plays `AudioResource`s, one at a time, into every subscribed voice session. |
| [`AudioResource`](/docs/reference/rust/zaun-client/struct-audioresource/) | Something to play: Opus packets, from an Ogg Opus file or stream, from ffmpeg (any format it reads), or from the application. |
| [`ui::Button`](/docs/reference/rust/zaun-client/struct-ui-button/) | A button: one that sends an interaction (`custom_id`), or a link the reader confirms. |
| [`registry::CatalogCheck`](/docs/reference/rust/zaun-client/struct-registry-catalogcheck/) | `verify_catalog`'s answer: the registry's report and, when `ok`, the verified catalog. |
| [`Channel`](/docs/reference/rust/zaun-client/struct-channel/) | A channel or category of a community. |
| [`ui::Checkbox`](/docs/reference/rust/zaun-client/struct-ui-checkbox/) | One yes/no box (type 23); never required. |
| [`ui::CheckboxGroup`](/docs/reference/rust/zaun-client/struct-ui-checkboxgroup/) | Several choices (type 22). |
| [`Client`](/docs/reference/rust/zaun-client/struct-client/) | A Zaun client. Clones share one SimpleX client and one driver; methods may be called from any thread, and block until the host answers or the timeout passes. |
| [`ClientBuilder`](/docs/reference/rust/zaun-client/struct-clientbuilder/) | Configures a `Client`. The directory holds the SimpleX store and `zaun/`, the community keys and state; give every client its own. |
| [`ui::CommandBuilder`](/docs/reference/rust/zaun-client/struct-ui-commandbuilder/) | A slash, user or message command. |
| [`Community`](/docs/reference/rust/zaun-client/struct-community/) | A community this client belongs to (or did: a handle outlives a leave). |
| [`CommunityData`](/docs/reference/rust/zaun-client/struct-communitydata/) | A community as this client last heard of it. Cheap to clone; a clone does not update. |
| [`ui::Container`](/docs/reference/rust/zaun-client/struct-ui-container/) | A box around other components (type 17). |
| [`DmChannel`](/docs/reference/rust/zaun-client/struct-dmchannel/) | A DM channel: an ordinary channel object of kind `dm` with its two participants. |
| [`EditMessage`](/docs/reference/rust/zaun-client/struct-editmessage/) | An edit of one of this member's messages. A plain `&str` replaces the text and leaves the embeds and mentions as they are. |
| [`EmbedBuilder`](/docs/reference/rust/zaun-client/struct-embedbuilder/) | A rich embed, built with chained setters and sent with `MessageOptions::embed`: |
| [`EphemeralReply`](/docs/reference/rust/zaun-client/struct-ephemeralreply/) | A bot's ephemeral reply (`EPHEMERAL`): only this member sees it, nothing stores it, and it lives as long as the interaction (15 minutes). Key it by its message's `message_id`. |
| [`FfmpegOptions`](/docs/reference/rust/zaun-client/struct-ffmpegoptions/) | How `AudioResource::ffmpeg_file` and its siblings transcode. |
| [`ui::File`](/docs/reference/rust/zaun-client/struct-ui-file/) | One attached file (type 13). |
| [`ui::FileUpload`](/docs/reference/rust/zaun-client/struct-ui-fileupload/) | Files the member uploads (type 19). |
| [`HandOff`](/docs/reference/rust/zaun-client/struct-handoff/) | What a hand-off signed and published: the new delegation and the descriptor naming it. |
| [`registry::HistoryCheck`](/docs/reference/rust/zaun-client/struct-registry-historycheck/) | `verify_history`'s answer: the registry's report and, when `ok`, the verified history. |
| [`Interaction`](/docs/reference/rust/zaun-client/struct-interaction/) | Someone used one of this bot's commands, components or modals. Answer within 3 s (`respond`, or `Response::defer` first); follow-ups and edits work for 15 minutes. |
| [`InteractionFailure`](/docs/reference/rust/zaun-client/struct-interactionfailure/) | An interaction that got no answer (the bot timed out, failed or is not running). |
| [`registry::KeyIdReport`](/docs/reference/rust/zaun-client/struct-registry-keyidreport/) | `key_id`'s answer. |
| [`ui::MediaGallery`](/docs/reference/rust/zaun-client/struct-ui-mediagallery/) | Up to ten pictures (type 12). |
| [`Member`](/docs/reference/rust/zaun-client/struct-member/) | A member of a community. |
| [`Message`](/docs/reference/rust/zaun-client/struct-message/) | A message in a channel. |
| [`MessageOptions`](/docs/reference/rust/zaun-client/struct-messageoptions/) | A message to post: text, embeds, files and the message it answers. A plain `&str` is one with text only, so `channel.send("hi")` still reads as it did. |
| [`ui::Modal`](/docs/reference/rust/zaun-client/struct-ui-modal/) | A modal: up to five labelled inputs and texts. |
| [`ModalOpen`](/docs/reference/rust/zaun-client/struct-modalopen/) | A bot asks this member to fill in a modal; submit it with `Channel::submit_modal` and `interaction` as the modal id. |
| [`ui::OptionBuilder`](/docs/reference/rust/zaun-client/struct-ui-optionbuilder/) | An option of a slash command. |
| [`PartialMessage`](/docs/reference/rust/zaun-client/struct-partialmessage/) | A message known only by its id, as an edit, a deletion or a reaction names it: the client keeps no message history, so its text and author are not at hand. It acts like a `Message` |
| [`PendingMessage`](/docs/reference/rust/zaun-client/struct-pendingmessage/) | A post on its way (`Channel::send_pending`): what to show until the host answers. |
| [`Presence`](/docs/reference/rust/zaun-client/struct-presence/) | A member's presence as everyone else sees it (`invisible` members look `Offline`). |
| [`ui::RadioGroup`](/docs/reference/rust/zaun-client/struct-ui-radiogroup/) | One choice among options (type 21). |
| [`Reaction`](/docs/reference/rust/zaun-client/struct-reaction/) | A reaction added or taken off. |
| [`Response`](/docs/reference/rust/zaun-client/struct-response/) | What a bot answers an interaction with. Build one with the constructors. |
| [`Role`](/docs/reference/rust/zaun-client/struct-role/) | A role of a community. |
| [`ui::Section`](/docs/reference/rust/zaun-client/struct-ui-section/) | One to three texts with a button or thumbnail beside them (type 9). |
| [`ui::Select`](/docs/reference/rust/zaun-client/struct-ui-select/) | A select menu. |
| [`ui::Separator`](/docs/reference/rust/zaun-client/struct-ui-separator/) | A line or a gap (type 14). |
| [`Suggestions`](/docs/reference/rust/zaun-client/struct-suggestions/) | A bot's suggestions for the option this member is typing. |
| [`ui::TextDisplay`](/docs/reference/rust/zaun-client/struct-ui-textdisplay/) | Markdown text (type 10). |
| [`ui::TextInput`](/docs/reference/rust/zaun-client/struct-ui-textinput/) | A text field. |
| [`ui::Thumbnail`](/docs/reference/rust/zaun-client/struct-ui-thumbnail/) | A picture beside a section (type 11). |
| [`TypingSeen`](/docs/reference/rust/zaun-client/struct-typingseen/) | A typing state and when it stops showing. |
| [`VoiceLeave`](/docs/reference/rust/zaun-client/struct-voiceleave/) | Why someone left a voice channel. |
| [`VoiceMute`](/docs/reference/rust/zaun-client/struct-voicemute/) | Someone's mute and deafen state in a voice channel. |
| [`VoiceOptions`](/docs/reference/rust/zaun-client/struct-voiceoptions/) | How a voice session connects. |
| [`VoiceSession`](/docs/reference/rust/zaun-client/struct-voicesession/) | One stay in a voice channel. Dropping it leaves the channel. |
| [`VoiceState`](/docs/reference/rust/zaun-client/struct-voicestate/) | Someone's state in a voice channel. |

## Type aliass

| Item | Summary |
|---|---|
| [`Result`](/docs/reference/rust/zaun-client/type-alias-result/) | `Result` with `Error`. |
