Skip to content

Enum command::Command

zaun_community_protocol::command::Command · Enum

pub enum Command { … }

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

session.hello

community.create

community.get

community.icon.get

community.rotations

community.update

CommunityDescriptorPublish(DescriptorPublish)

Section titled “CommunityDescriptorPublish(DescriptorPublish)”

community.descriptor.publish

community.leave

channel.create

channel.update

channel.delete

channel.reorder

ChannelPermissionsUpdate(PermissionsUpdate)

Section titled “ChannelPermissionsUpdate(PermissionsUpdate)”

channel.permissions.update

member.list

member.get

member.update

member.roles.update

member.kick

member.ban

member.unban

member.bans

member.timeout

member.status.set

role.create

role.update

role.delete

role.reorder

message.send

message.edit

message.delete

message.history

reaction.add

reaction.remove

attachment.upload

attachment.download

invite.create

invite.redeem

invite.revoke

invite.list

invite.uses

audit.list

sync.snapshot

sync.events

sync.resume

sync.ack

membership.request

membership.approve

membership.reject

membership.suspend

membership.restore

membership.pending

admission.policy.get

admission.policy.update

moderation.lockdown.get

moderation.lockdown.enable

moderation.lockdown.disable

report.create

report.list

report.get

report.review

report.resolve

voice.join

voice.leave

voice.update

voice.signal

voice.keys

voice.moderate

signal.typing

signal.presence

presence.list

migration.reauth

bot.install

bot.update

bot.grant

bot.enable

bot.disable

bot.remove

bot.register

bot.configure

bot.list

bot.get

command.set

command.list

interaction.create

interaction.respond

interaction.followup

interaction.original.edit

interaction.original.delete

dm.open

dm.close

dm.list

member.settings.get

member.settings.update

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.

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

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.

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

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

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

The wire name (type).

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

Runs the body’s state-free checks.

The first violated rule.

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

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.

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

Clone, Debug, PartialEq, StructuralPartialEq

Full rustdoc page