# Struct CommunityData

> A community as this client last heard of it. Cheap to clone; a clone does not update.

`zaun_client::CommunityData` · Struct

```rust
pub struct CommunityData { … }
```

A community as this client last heard of it. Cheap to clone; a clone does not update.

Every map is bounded by the community itself: entries leave when the host reports the
channel, role or member gone. `members` holds the members this client has heard of
(events, `Community::fetch_members`), not always all.

## Fields

### `id: CommunityId`

The community.

### `me: MemberId`

This client's member id in it.

### `is_owner: bool`

Whether this client is the owner.

### `loaded: bool`

The host's snapshot has loaded at least once (`Event::Ready`
was said).

### `name: String`

The community's name, from its descriptor as the host's welcome proved it (empty
until then).

### `description: Option<String>`

Its description, from the same descriptor.

### `profile: Option<CommunityProfile>`

The host-managed profile, once the snapshot has it.

### `channels: BTreeMap<ChannelId, Channel>`

Channels and categories this member can see.

### `dms: BTreeMap<ChannelId, DmChannel>`

DM: this member's open direct messages with bots, by channel. Entries leave when the
DM is closed here or the community is.

### `roles: BTreeMap<RoleId, Role>`

Roles, `@everyone` (`RoleId::EVERYONE`) included.

### `members: BTreeMap<MemberId, Member>`

Members heard of, this client included once the snapshot arrived.

### `attachments: Option<HostAttachments>`

What the host takes as attachments (its largest file, the file servers it downloads
from), from its last welcome; `None` before one, or when the host did not say.

### `capabilities: Vec<String>`

The capabilities this client and the host both support (`frag`, `embeds`, …), from the
host's last welcome; empty before one. Replaced at each welcome, so it never grows.

### `commands: BTreeMap<CommandId, ApplicationCommand>`

The bots' application commands, each with its `bot_id`. A bot's whole list is
replaced by `command.updated` and dropped with the bot, so it never outgrows the bots.

### `bots: BTreeMap<BotId, BotCard>`

Installed bots' public cards; an entry leaves with `bot.removed`.

### `typing: BTreeMap<ChannelId, TypingSeen>`

Typing: who else is typing per channel (`CommunityData::typing_in`). One entry per
channel, replaced by each `signal.typing`, gone with the channel.

### `presences: BTreeMap<MemberId, PresenceSignal>`

Presence: every member not offline, as others see them (`presence.list`, then each
`signal.presence`); see `CommunityData::presence_of`.

## Methods

### `supports`

```rust
pub fn supports(&self, capability: &str) -> bool
```

Whether the host's last welcome listed `capability`.

### `channel_by_name`

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

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

### `role_by_name`

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

The first role named `name`.

### `ordered_channels`

```rust
pub fn ordered_channels(&self) -> Vec<&Channel>
```

Channels in display order: by position, categories' children after them.

### `permissions`

```rust
pub fn permissions(&self, member: &MemberId, channel: Option<&ChannelId>, now_ms: u64) -> Option<Resolved>
```

What `member` may do in `channel` (or community-wide with `None`) at `now_ms`, or `None`
when the member or the channel is not in the cache.

### `can`

```rust
pub fn can(&self, member: &MemberId, channel: Option<&ChannelId>, bits: Permissions, now_ms: u64) -> bool
```

Whether `member` has every bit of `bits` in `channel` at `now_ms` (see
`permissions`); `false` when the cache does not know.

### `can_use`

```rust
pub fn can_use(&self, member: &MemberId, channel: &ChannelId, command: &ApplicationCommand, now_ms: u64) -> bool
```

Whether `member` may use bot command `command` in `channel`: `VIEW_CHANNEL` and
`USE_APPLICATION_COMMANDS` there, plus the command's `default_member_permissions`
(`"0"`: the owner only). As the rest of this view, it can show more than the host allows.

### `presence_of`

```rust
pub fn presence_of(&self, member: MemberId) -> Presence
```

`member`'s presence (offline when the cache has none).

### `typing_in`

```rust
pub fn typing_in(&self, channel: &ChannelId, now_ms: u64) -> Option<&TypingNow>
```

Who else is typing in `channel` at `now_ms`, if anyone.

### `typing_mode`

```rust
pub fn typing_mode(&self, channel: &ChannelId) -> TypingMode
```

The channel's typing setting (`named` when the cache does not have the channel).

## Trait implementations

`Clone`, `Debug`, `PartialEq`, `Serialize`, `StructuralPartialEq`

[Full rustdoc page](/docs/api/rust/zaun-client/zaun_client/cache/struct.CommunityData.html)
