<!--
{
  "availability" : [

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

# ControlProtocolParser

Namespace enum holding all stateless control-protocol parsing routines.

```
enum ControlProtocolParser
```

## Overview

Every method is `static` — the enum exists only as a namespace, never
instantiated. Callers invoke
[`parseReply(_:)`](/documentation/Tor/ControlProtocolParser/parseReply(_:)) to turn the raw lines from
[`readReply()`](/documentation/Tor/ControlSocket/readReply()) into a [`ControlReply`](/documentation/Tor/ControlReply), then route
through type-specific helpers like
[`parseAddOnionResponse(_:)`](/documentation/Tor/ControlProtocolParser/parseAddOnionResponse(_:)-rg89)
or [`parseGetInfoResponse(_:)`](/documentation/Tor/ControlProtocolParser/parseGetInfoResponse(_:)) for semantic
decoding.

The reply formats swift-tor decodes follow control-spec.txt §2.3:
**single-line** (`250 OK\r\n`), **multi-line continuation**
(`250-line1\r\n250-line2\r\n250 OK\r\n`), **data block**
(`250+key=\r\nbody-line-1\r\n.\r\n250 OK\r\n`), and **async event**
(`650 EVENT_TYPE payload\r\n`).

> Note: The parser is allocation-light but not zero-allocation — it
> slices `String` views of the input lines. For tight loops over
> thousands of events per second, prefer direct attribute access on
> the raw lines.

> Important: All `parse*` methods are safe to call concurrently and
> deterministic: same input, same output.

## Topics

### Replies

[`parseReply(_:)`](/documentation/Tor/ControlProtocolParser/parseReply(_:))

Parse an array of raw reply lines into a [`ControlReply`](/documentation/Tor/ControlReply).

[`parseSingleLine(_:)`](/documentation/Tor/ControlProtocolParser/parseSingleLine(_:))

Convenience: parse exactly one reply line.

### Structured decoders

[`parseBootstrapStatus(_:)`](/documentation/Tor/ControlProtocolParser/parseBootstrapStatus(_:))

Parse a `BOOTSTRAP` status line into a [`BootstrapStatus`](/documentation/Tor/BootstrapStatus).

[`parseAddOnionResponse(_:)`](/documentation/Tor/ControlProtocolParser/parseAddOnionResponse(_:)-rg89)

Decode an already-parsed [`ControlReply`](/documentation/Tor/ControlReply) into an
[`AddOnionResponse`](/documentation/Tor/AddOnionResponse).

[`parseAddOnionResponse(_:)`](/documentation/Tor/ControlProtocolParser/parseAddOnionResponse(_:)-7qmef)

Decode an `ADD_ONION` response directly from raw reply lines.

[`parseGetInfoResponse(_:)`](/documentation/Tor/ControlProtocolParser/parseGetInfoResponse(_:))

Decode a `GETINFO` reply into a `[key: value]` dictionary.

### Async events

[`parseAsyncEvent(_:)`](/documentation/Tor/ControlProtocolParser/parseAsyncEvent(_:))

Decode a `650`-status async-event line into a typed message.

### Primitives

[`parseAttributes(_:)`](/documentation/Tor/ControlProtocolParser/parseAttributes(_:))

Lift `KEY=VALUE` and `KEY="quoted value"` attributes into a
dictionary.

