Skip to content

Finesse @available guards: document rationale and relax over-annota…#8

Open
rnro wants to merge 1 commit into
apple:mainfrom
rnro:availability_2
Open

Finesse @available guards: document rationale and relax over-annota…#8
rnro wants to merge 1 commit into
apple:mainfrom
rnro:availability_2

Conversation

@rnro

@rnro rnro commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

…tions

Every @available annotation in Sources/ and Tests/ now carries a // Availability due to ... comment naming the underlying type or feature that drives the OS floor (e.g. Swift's RawSpan, os.log's Logger, CryptoKit's P256.Signing.PublicKey, CryptoKit's MLKEM768). Reading the source no longer requires inferring why each guard is there.

Use the actual binding type's availability instead of SwiftTLS 0.1.0 (= macOS 26+) where it's lower:

  • Types whose only OS-bound dependency is P256.Signing.{PublicKey, PrivateKey}PrivateKey, PublicKey, their conformance extensions, BackingPrivateKey, SwiftTLSOpaqueReferenceKey — drop to macOS 11, iOS 14, tvOS 14, watchOS 7, * (the P256 Apple-CryptoKit floor).
  • struct Curve25519EphemeralKey in KeyExchange.swift drops to macOS 10.15, iOS 13, tvOS 13, watchOS 6, * — its body only references Curve25519, available at those versions since CryptoKit shipped.

Drop the @available entirely on declarations that have no OS-bound dependency:

  • enum LatestError and func errorCodeFromLatestError in SwiftTLSProtocol.swift — both reference only stdlib types.
  • public typealias SwiftTLSSignatureScheme (a UInt16 alias) and public typealias SwiftTLSRefKeySignCallback (a closure over stdlib Data and the alias above) in PrivateKey.swift — neither references an OS-bound type.
  • Various other declarations whose bodies only touch stdlib / NIO core / always-available APIs.

…tions

Every `@available` annotation in `Sources/` and `Tests/` now carries a
`// Availability due to ...` comment naming the underlying type or feature
that drives the OS floor (e.g. `Swift`'s `RawSpan`, `os.log`'s `Logger`,
`CryptoKit`'s `P256.Signing.PublicKey`, `CryptoKit`'s `MLKEM768`). Reading
the source no longer requires inferring why each guard is there.

Use the actual binding type's availability instead of `SwiftTLS 0.1.0`
(= macOS 26+) where it's lower:

* Types whose only OS-bound dependency is `P256.Signing.{PublicKey,
  PrivateKey}` — `PrivateKey`, `PublicKey`, their conformance extensions,
  `BackingPrivateKey`, `SwiftTLSOpaqueReferenceKey` — drop to
  `macOS 11, iOS 14, tvOS 14, watchOS 7, *` (the P256 Apple-CryptoKit
  floor).
* `struct Curve25519EphemeralKey` in `KeyExchange.swift` drops to
  `macOS 10.15, iOS 13, tvOS 13, watchOS 6, *` — its body only references
  `Curve25519`, available at those versions since CryptoKit shipped.

Drop the `@available` entirely on declarations that have no OS-bound
dependency:

* `enum LatestError` and `func errorCodeFromLatestError` in
  `SwiftTLSProtocol.swift` — both reference only stdlib types.
* `public typealias SwiftTLSSignatureScheme` (a `UInt16` alias) and
  `public typealias SwiftTLSRefKeySignCallback` (a closure over stdlib
  `Data` and the alias above) in `PrivateKey.swift` — neither references
  an OS-bound type.
* Various other declarations whose bodies only touch stdlib / NIO core /
  always-available APIs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant