# Enum command::Command

> A decoded command body: one variant per command of the protocol

`zaun_community_protocol::command::Command` · Enum

```rust
pub enum Command { … }
```

A decoded command body: one variant per command of the protocol

## Variants

### `SessionHello(Hello)`

`session.hello`

### `CommunityCreate(Create)`

`community.create`

### `CommunityGet(Get)`

`community.get`

### `CommunityIconGet(IconGet)`

`community.icon.get`

### `CommunityRotations(Rotations)`

`community.rotations`

### `CommunityUpdate(Update)`

`community.update`

### `CommunityDescriptorPublish(DescriptorPublish)`

`community.descriptor.publish`

### `CommunityLeave(Leave)`

`community.leave`

### `ChannelCreate(Create)`

`channel.create`

### `ChannelUpdate(Update)`

`channel.update`

### `ChannelDelete(Delete)`

`channel.delete`

### `ChannelReorder(Reorder)`

`channel.reorder`

### `ChannelPermissionsUpdate(PermissionsUpdate)`

`channel.permissions.update`

### `MemberList(List)`

`member.list`

### `MemberGet(Get)`

`member.get`

### `MemberUpdate(Update)`

`member.update`

### `MemberRolesUpdate(RolesUpdate)`

`member.roles.update`

### `MemberKick(Kick)`

`member.kick`

### `MemberBan(BanMember)`

`member.ban`

### `MemberUnban(Unban)`

`member.unban`

### `MemberBans(Bans)`

`member.bans`

### `MemberTimeout(Timeout)`

`member.timeout`

### `MemberStatusSet(StatusSet)`

`member.status.set`

### `RoleCreate(Create)`

`role.create`

### `RoleUpdate(Update)`

`role.update`

### `RoleDelete(Delete)`

`role.delete`

### `RoleReorder(Reorder)`

`role.reorder`

### `MessageSend(Send)`

`message.send`

### `MessageEdit(Edit)`

`message.edit`

### `MessageDelete(Delete)`

`message.delete`

### `MessageHistory(History)`

`message.history`

### `ReactionAdd(ReactionAdd)`

`reaction.add`

### `ReactionRemove(ReactionRemove)`

`reaction.remove`

### `AttachmentUpload(Upload)`

`attachment.upload`

### `AttachmentDownload(Download)`

`attachment.download`

### `InviteCreate(Create)`

`invite.create`

### `InviteRedeem(Redeem)`

`invite.redeem`

### `InviteRevoke(Revoke)`

`invite.revoke`

### `InviteList(List)`

`invite.list`

### `InviteUses(Uses)`

`invite.uses`

### `AuditList(List)`

`audit.list`

### `SyncSnapshot(Snapshot)`

`sync.snapshot`

### `SyncEvents(Events)`

`sync.events`

### `SyncResume(Resume)`

`sync.resume`

### `SyncAck(Ack)`

`sync.ack`

### `MembershipRequest(Request)`

`membership.request`

### `MembershipApprove(Approve)`

`membership.approve`

### `MembershipReject(Reject)`

`membership.reject`

### `MembershipSuspend(Suspend)`

`membership.suspend`

### `MembershipRestore(Restore)`

`membership.restore`

### `MembershipPending(Pending)`

`membership.pending`

### `AdmissionPolicyGet(PolicyGet)`

`admission.policy.get`

### `AdmissionPolicyUpdate(PolicyUpdate)`

`admission.policy.update`

### `LockdownGet(Get)`

`moderation.lockdown.get`

### `LockdownEnable(Enable)`

`moderation.lockdown.enable`

### `LockdownDisable(Disable)`

`moderation.lockdown.disable`

### `ReportCreate(Create)`

`report.create`

### `ReportList(List)`

`report.list`

### `ReportGet(Get)`

`report.get`

### `ReportReview(Review)`

`report.review`

### `ReportResolve(Resolve)`

`report.resolve`

### `VoiceJoin(Join)`

`voice.join`

### `VoiceLeave(Leave)`

`voice.leave`

### `VoiceUpdate(Update)`

`voice.update`

### `VoiceSignal(Signal)`

`voice.signal`

### `VoiceKeys(Keys)`

`voice.keys`

### `VoiceModerate(Moderate)`

`voice.moderate`

### `SignalTyping(Typing)`

`signal.typing`

### `SignalPresence(Presence)`

`signal.presence`

### `PresenceList(List)`

`presence.list`

### `MigrationReauth(Reauth)`

`migration.reauth`

### `BotInstall(Install)`

`bot.install`

### `BotUpdate(Update)`

`bot.update`

### `BotGrant(Grant)`

`bot.grant`

### `BotEnable(Enable)`

`bot.enable`

### `BotDisable(Disable)`

`bot.disable`

### `BotRemove(Remove)`

`bot.remove`

### `BotRegister(Register)`

`bot.register`

### `BotConfigure(Configure)`

`bot.configure`

### `BotList(List)`

`bot.list`

### `BotGet(Target)`

`bot.get`

### `CommandSet(Set)`

`command.set`

### `CommandList(List)`

`command.list`

### `InteractionCreate(Create)`

`interaction.create`

### `InteractionRespond(Respond)`

`interaction.respond`

### `InteractionFollowup(Followup)`

`interaction.followup`

### `InteractionOriginalEdit(OriginalEdit)`

`interaction.original.edit`

### `InteractionOriginalDelete(OriginalDelete)`

`interaction.original.delete`

### `DmOpen(Open)`

`dm.open`

### `DmClose(Close)`

`dm.close`

### `DmList(List)`

`dm.list`

### `MemberSettingsGet(SettingsGet)`

`member.settings.get`

### `MemberSettingsUpdate(SettingsUpdate)`

`member.settings.update`

## Methods

### `is_channel_scoped`

```rust
pub fn is_channel_scoped(&self) -> bool
```

Whether the command needs a channel: the envelope's `channel_id` or the body's
(`Command::channel_id`). `invite.create` and `sync.events` name an optional or
stream-dependent channel in the body only and are not listed.

### `channel_id`

```rust
pub const fn channel_id(&self) -> Option<ChannelId>
```

The `channel_id` carried in the body, for commands whose the protocol/the protocol body lists one.
When both the envelope and the body carry one they must be equal (envelope layer).

### `is_mutating`

```rust
pub fn is_mutating(&self) -> bool
```

Whether the command is mutating, hence idempotency-recorded; the same rule as
`crate::envelope::is_mutating` on the command's wire name.

### `validate_at`

```rust
pub fn validate_at(&self, now_ms: u64) -> Result<(), BodyError>
```

`Command::validate` plus the bounds relative to the host's clock: `member.timeout`
`until` ≤ now + 28 days and `membership.suspend` `until` ≤ now + 90 days.

SPEC: whether an `until` in the past is an error is not said; it is accepted here
(the engine treats it as already elapsed).

# Errors
As `Command::validate`, or `BAD_REQUEST{field: "until"}`.

### `name`

```rust
pub const fn name(&self) -> &'static str
```

The wire name (`type`).

### `validate`

```rust
pub fn validate(&self) -> Result<(), BodyError>
```

Runs the body's state-free checks.

# Errors
The first violated rule.

### `visit`

```rust
pub fn visit<V>(&self, visitor: V) -> <V as >::Output
```

Calls `visitor` with the typed body (to send a command known only at run time).

### `parse`

```rust
pub fn parse(type_: &str, body: &str) -> Result<Self, BodyError>
```

Decodes `body` (the envelope's raw `body` JSON) as the command `type_` and runs its
state-free checks.

# Errors
- `type_` unknown or in a the protocol namespace → `BodyError::UnsupportedCommand`;
- a the protocol reserved command → `BodyError::UnsupportedFeature` naming it;
- a malformed body → `BodyError::BadRequest` (with the top-level field when known);
- a failed check → whatever `Command::validate` returns.

## Trait implementations

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

[Full rustdoc page](/docs/api/rust/zaun-community-protocol/zaun_community_protocol/command/enum.Command.html)
