Server.using(_:_:)
Swift
- Python Unavailable
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust Unavailable
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift
- Declared in
- Server
- Package
- libtmux-swift
- Source
- Sources/LibTmux/ControlMode.swift
-
-
Runs
bodywith this server inmode.The one switch. Every call inside is the call you would write anyway and hands back the type it would hand back anyway;
modedecides only how it travels. Reach for this when the choice is made at runtime — a flag, a config, a benchmark running both — so it stays a value rather than two shapes of code:Scoped even for
TmuxMode/direct, where nothing needs closing, so that the two read identically at the call site.connected(attachingTo:_:)is the same thing with the connection handed over as well, for the one capability a process does not have.Modes nest, and the innermost wins:
using(.direct)inside a connected scope gives back a server that spawns processes, which is the supported way to keep one call off a connection. A server handed to a connectedbodydoes not keep that connection alive when returned or stored.Examples
let mode: TmuxMode = attachToExisting ? .connected(to: "main") : .directlet names = try await server.using(mode) { server intry await server.sessions().map(\.name)}- Raises
0 declared, 0 inherited