# Struct envelope::ResponseEnvelope

> `{ "v", "type": "response", "request_id", "ok", "body" | "error" }`.

`zaun_community_protocol::envelope::ResponseEnvelope` · Struct

```rust
pub struct ResponseEnvelope { … }
```

`{ "v", "type": "response", "request_id", "ok", "body" | "error" }`.

`request_id` is `null` when the command's id could not be read.

## Fields

### `v: u16`

Envelope version.

### `request_id: Option<RequestId>`

The command's `request_id`, or `None` (`null`).

### `outcome: Outcome`

Success body or error.

## Methods

### `ok`

```rust
pub fn ok(request_id: RequestId, body: Box<RawValue>) -> Self
```

A success response at `PROTOCOL_VERSION`.

### `ok_json`

```rust
pub fn ok_json<T>(request_id: RequestId, body: &T) -> Result<Self>
```

A success response whose body is serialised from `body`.

# Errors
`body` fails to serialise as JSON.

### `error`

```rust
pub fn error(request_id: Option<RequestId>, error: ErrorBody) -> Self
```

An error response at `PROTOCOL_VERSION`.

### `error_body`

```rust
pub fn error_body(&self) -> Option<&ErrorBody>
```

The error, if this is a failure.

### `is_recorded`

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

Whether this response is stored as the idempotency record: every success and
every error except `BUSY`, `RATE_LIMITED`, `INTERNAL` and `SLOWMODE_ACTIVE`.

## Trait implementations

`Clone`, `Debug`, `Deserialize<'de>`, `Serialize`

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