Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Swift API

Swift documentation

Server.using(_:_:)

Swift
  • Python Unavailable
  • Ruby Unavailable
  • Lua Unavailable
  • TypeScript Unavailable
  • Rust Unavailable
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift

View as Markdown

Declared in
Server
Package
libtmux-swift
Source
Sources/LibTmux/ControlMode.swift
using(_:_:) ( mode : TmuxMode , body : @escaping (Server) async throws -> Result ) → Result
methodasync [source]
methodasync [source]
using(_:_:)

Runs body with this server in mode .

The one switch. Every call inside is the call you would write anyway and hands back the type it would hand back anyway; mode decides 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 connected body does not keep that connection alive when returned or stored.

Examples

let mode: TmuxMode = attachToExisting ? .connected(to: "main") : .direct
let names = try await server.using(mode) { server in
try await server.sessions().map(\.name)
}
Raises

0 declared, 0 inherited

Esc

Type to search.