<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Tor",
  "identifier" : "/documentation/Tor/ControlReply",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Tor"
    ],
    "preciseIdentifier" : "s:3Tor12ControlReplyV"
  },
  "title" : "ControlReply"
}
-->

# ControlReply

A fully-parsed Tor control-protocol reply, ready for business logic.

```
struct ControlReply
```

## Overview

Represents the result of parsing one or more raw lines from
[`readReply()`](/documentation/Tor/ControlSocket/readReply()) into a single semantic unit per
control-spec.txt §2.3: a numeric status code, the content lines
(stripped of the `NNN<sep>` prefix), and an optional verbatim data
block (for `NNN+` replies terminated by a sole `.`).

> Note: Conformance is `Sendable` + `Equatable`; synthesised
> equality compares `statusCode`, `lines` (element-wise), and `data`
> verbatim.

> Important: `ControlReply` makes no claim about whether a reply
> is semantically valid for the command that elicited it — only
> that the wire format parsed. Per-command parsers
> (``doc://Tor/documentation/Tor/ControlProtocolParser/parseAddOnionResponse(_:)-rg89``
> et al.) validate payload shape on top.

## Topics

### Core fields

[`statusCode`](/documentation/Tor/ControlReply/statusCode)

The numeric status code of the reply (control-spec.txt §2.3).

[`lines`](/documentation/Tor/ControlReply/lines)

The reply content lines, with the status-code prefix stripped.

[`data`](/documentation/Tor/ControlReply/data)

Verbatim data-block contents from a `NNN+` reply, if any.

### Classification

[`isSuccess`](/documentation/Tor/ControlReply/isSuccess)

`true` when the status code is in the 2xx range.

[`isError`](/documentation/Tor/ControlReply/isError)

`true` when the status code is 4xx or 5xx.

[`message`](/documentation/Tor/ControlReply/message)

The first content line, or an empty string for empty replies.

### Structured access

[`keyValuePairs`](/documentation/Tor/ControlReply/keyValuePairs)

Extract `KEY=VALUE` pairs from [`lines`](/documentation/Tor/ControlReply/lines) into a dictionary.

### Creating

[`init(statusCode:lines:data:)`](/documentation/Tor/ControlReply/init(statusCode:lines:data:))

Memberwise initialiser — usually invoked by parsers, not by
application code.

