Instance Method
start()
Start the embedded Tor process.
func start() async throws
Mentioned In
Discussion
Orchestrates the cross-thread dance that brings Tor up:
Create dataDirectory (and parents) with FileManager.createDirectory(atPath:withIntermediateDirectories:).
Call tor_main_configuration_new(), stamp the configuration with our torrc-equivalent argv, and hand it tor_main_configuration_setup_control_socket() to obtain a pre-authenticated embedded control socket.
Post tor_run_main() to a dedicated Thread; bridge its synchronous startup back to the actor with a CheckedContinuation.
Bind a TorControlClient to the socket and populate socksEndpoint via GETINFO net/listeners/socks (control-spec.txt ยง3.9).
Resolves once steps 1โ4 complete, at which point state advances to TorState.running. Bootstrap progress is still in flight โ pair with waitUntilBootstrapped(timeout:) to block until Tor is actually ready to carry user traffic.
Throws
TorError.alreadyStarted when state is TorState.starting, TorState.running, or TorState.stopping; TorError.startFailed(_:) when tor_run_main() returns non-zero or the argv is rejected.
Important
This method is idempotent only for terminal states (TorState.idle, TorState.stopped, TorState.failed(_:)); double-starting while state is transient throws.