# Struct envelope::CommandEnvelope

> `{ "v", "type", "request_id", "community_id", "channel_id"?, "body" }`.

`zaun_community_protocol::envelope::CommandEnvelope` · Struct

```rust
pub struct CommandEnvelope { … }
```

`{ "v", "type", "request_id", "community_id", "channel_id"?, "body" }`.

Parse received text with `super::parse_command`; serialise with serde (client side).
`body` is the command's body object exactly as received, for the `command` module to parse
by `type` and for the idempotency hash.

## Fields

### `v: u16`

Envelope version.

### `kind: String`

Command name.

### `request_id: Option<RequestId>`

Correlation id; `None` (`null`) only for `signal.*` commands.

### `community_id: Option<CommunityId>`

The bound community, or the target of `community.create` / `invite.redeem`; else `null`.

### `channel_id: Option<ChannelId>`

Present for channel-scoped commands.

### `body: Box<RawValue>`

The body object, `{}` when empty.

## Methods

### `new`

```rust
pub fn new<impl Into<String>>(kind: impl Into<String>, request_id: Option<RequestId>, community_id: Option<CommunityId>, channel_id: Option<ChannelId>, body: Box<RawValue>) -> Self
```

A command at `PROTOCOL_VERSION`.

### `is_signal`

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

Whether this is an ephemeral signal (`signal.*`): no response, no idempotency record.

### `is_mutating`

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

Whether the command is mutating, hence idempotency-recorded.

### `body_hash`

```rust
pub fn body_hash(&self) -> BodyHash
```

SHA3-256 of the body JSON text as received.

## Trait implementations

`Clone`, `Debug`, `Serialize`

[Full rustdoc page](/docs/api/rust/zaun-community-protocol/zaun_community_protocol/envelope/command_envelope/struct.CommandEnvelope.html)
