<!--
{
  "availability" : [

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

# TorEvent

Lifecycle and protocol events surfaced by [`TorClient`](/documentation/Tor/TorClient) and
[`TorSession`](/documentation/Tor/TorSession).

```
enum TorEvent
```

## Overview

`TorEvent` is the Swift-side projection of Tor’s control-protocol
async events (control-spec.txt §4) plus swift-tor’s own state
transitions. It flattens heterogeneous sources — bootstrap progress,
log messages, state changes, and circuit/stream status — into a
single `Sendable` enum so UI code can subscribe to one `AsyncStream`
and pattern-match once.

The enum does **not** cover every control-protocol event Tor can
emit; only the high-level events that map cleanly to end-user UX or
state machines are surfaced here. For the complete raw-event set,
subscribe via [`subscribe(to:)`](/documentation/Tor/TorControlClient/subscribe(to:)) and receive
[`TorControlEventMessage`](/documentation/Tor/TorControlEventMessage) values directly.

> Note: Events are delivered in causal order per
> ``doc://Tor/documentation/Tor/TorSession/events``. A `.stateChanged(.running)` is never observed
> before the `.stateChanged(.starting)` that preceded it.

> Important: The stream has no replay. Subscribers that start late
> will miss earlier events — capture the initial state via
> ``doc://Tor/documentation/Tor/TorClient/state`` when opening the iterator.

## Topics

### Cases

[`TorEvent.bootstrap(progress:tag:summary:)`](/documentation/Tor/TorEvent/bootstrap(progress:tag:summary:))

Bootstrap progress update derived from Tor’s
`status/bootstrap-phase` GETINFO key.

[`TorEvent.log(level:message:)`](/documentation/Tor/TorEvent/log(level:message:))

A log line emitted by Tor at the specified severity.

[`TorEvent.stateChanged(_:)`](/documentation/Tor/TorEvent/stateChanged(_:))

[`TorClient`](/documentation/Tor/TorClient)’s [`TorState`](/documentation/Tor/TorState) advanced to a new value.

[`TorEvent.circuit(id:status:)`](/documentation/Tor/TorEvent/circuit(id:status:))

A Tor circuit changed status (built, extended, closed, failed).

[`TorEvent.stream(id:status:target:)`](/documentation/Tor/TorEvent/stream(id:status:target:))

A Tor stream (connection) changed status.

