Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let versionNumbers = ["0.1.0"]
// Availability Macro Utilities

enum _OSAvailability: String {
// This should match the package's deployment target
// The OS versions in which `Network 0.1.0` APIs first became available.
case alwaysAvailable = "macOS 26, iOS 26, tvOS 26, watchOS 26, visionOS 26"
// Use 10000 for future availability to avoid compiler magic around the 9999 version number but ensure it is greater than 9999
case future = "macOS 10000, iOS 10000, tvOS 10000, watchOS 10000, visionOS 10000"
Expand Down Expand Up @@ -46,6 +46,7 @@ var settings: [SwiftSetting] = [
.define("SWIFTTLS_CERTIFICATE_VERIFICATION"),
.unsafeFlags(["-Xfrontend", "-experimental-spi-only-imports"]),
.enableExperimentalFeature("Lifetimes"),
.enableExperimentalFeature("AnyAppleOSAvailability"),
.enableUpcomingFeature("ExistentialAny"),
]

Expand Down Expand Up @@ -88,9 +89,6 @@ settings.append(.define("SHIM_CRYPTO_SPAN_APIS"))

let package = Package(
name: "swift-network-evolution",
platforms: [
.macOS("26.0"), .iOS("26.0"), .tvOS("26.0"), .watchOS("26.0"), .visionOS("26.0"),
],
products: [
.library(
name: "SwiftNetwork",
Expand Down Expand Up @@ -143,52 +141,52 @@ let package = Package(
.target(
name: "SwiftNetworkBenchmarks",
dependencies: targetDependencies + ["SwiftNetwork"],
swiftSettings: settings
swiftSettings: availabilityMacros + settings
),
.testTarget(
name: "SwiftNetworkTests",
dependencies: ["SwiftNetwork"],
swiftSettings: settings
swiftSettings: availabilityMacros + settings
),
.testTarget(
name: "QUICTests",
dependencies: ["SwiftNetwork"],
swiftSettings: settings
swiftSettings: availabilityMacros + settings
),
.executableTarget(
name: "QUICHandshake",
dependencies: ["SwiftNetwork", "SwiftNetworkBenchmarks"],
path: "Sources/Tools/QUICHandshake",
exclude: ["README.md"],
swiftSettings: settings,
swiftSettings: availabilityMacros + settings,
),
.executableTarget(
name: "IPUDPTransfer",
dependencies: ["SwiftNetwork", "SwiftNetworkBenchmarks"],
path: "Sources/Tools/IPUDPTransfer",
exclude: ["README.md"],
swiftSettings: settings
swiftSettings: availabilityMacros + settings
),
.executableTarget(
name: "QUICTransfer",
dependencies: ["SwiftNetwork", "SwiftNetworkBenchmarks"],
path: "Sources/Tools/QUICTransfer",
exclude: ["README.md"],
swiftSettings: settings
swiftSettings: availabilityMacros + settings
),
.executableTarget(
name: "QUICStreamLoad",
dependencies: ["SwiftNetwork", "SwiftNetworkBenchmarks"],
path: "Sources/Tools/QUICStreamLoad",
exclude: ["README.md"],
swiftSettings: settings
swiftSettings: availabilityMacros + settings
),
.executableTarget(
name: "SocketTransfer",
dependencies: ["SwiftNetwork", "SwiftNetworkBenchmarks"],
path: "Sources/Tools/SocketTransfer",
exclude: ["README.md"],
swiftSettings: settings
swiftSettings: availabilityMacros + settings
),
]
)
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/Connection/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public protocol NetworkProtocolOptions {
func configure(parameters: Parameters)
}

@available(Network 0.1.0, *)
extension NetworkProtocolOptions {
public var belowProtocol: BelowProtocol {
fatalError("This should not be called")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//

#if !NETWORK_EMBEDDED
@available(Network 0.1.0, *)
struct DataTransferSnapshot: Equatable {
var interfaceIndex: UInt64?

Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftNetwork/Context/NetworkContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public final class NetworkContext: NetworkContextProtocol, @unchecked Sendable {
// MARK: - Globals

#if !NETWORK_PRIVATE && !NETWORK_STANDALONE && canImport(Dispatch) && !NETWORK_EMBEDDED
@available(Network 0.1.0, *)
extension NetworkContext {
struct TimerEntry: ~Copyable, NetworkComparable {
var targetTime: DispatchTime
Expand Down Expand Up @@ -369,6 +370,7 @@ extension NetworkContext {

// MARK: - Async

@available(Network 0.1.0, *)
extension NetworkContext {

var queue: DispatchQueue {
Expand All @@ -392,6 +394,7 @@ extension NetworkContext {

// MARK: - Timers

@available(Network 0.1.0, *)
extension NetworkContext {

enum FutureTime {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftNetwork/Endpoint/EndpointCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public struct EndpointEqualityFlags: OptionSet, Sendable {
static public let all: EndpointEqualityFlags = [.interface, .parent, .proxyParent, .alternatives, .publicKeys]
}

@available(Network 0.1.0, *)
extension Endpoint.EndpointType {
enum EndpointRawType: UInt32 {
case invalid = 0
Expand Down Expand Up @@ -81,6 +82,7 @@ extension Endpoint.EndpointType {
}
}

@available(Network 0.1.0, *)
protocol EndpointProtocol: CustomStringConvertible {
var interface: Interface? { get }
func isEqual(to other: Self, flags: EndpointEqualityFlags) -> Bool
Expand Down Expand Up @@ -132,13 +134,15 @@ public protocol EndpointCommonProtocol: Hashable, Equatable {
}

#if !NETWORK_PRIVATE
@available(Network 0.1.0, *)
extension EndpointCommonProtocol {
var interface: Interface? {
get { common.interface }
set { common = EndpointCommon(interface: newValue) }
}
}

@available(Network 0.1.0, *)
extension EndpointCommon {
init?(_ data: inout [UInt8]) {
self.interface = nil
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/Endpoint/EthernetAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

@available(Network 0.1.0, *)
public struct EthernetAddress: Hashable, CustomDebugStringConvertible {

public static var broadcast: EthernetAddress {
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/Endpoint/IPv6Address.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

@available(Network 0.1.0, *)
public struct IPv6Address: IPAddress, Hashable, CustomDebugStringConvertible {

/// The IPv6 "any" address.
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/EndpointFlow/EndpointFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal import os
internal import Synchronization
#endif

@available(Network 0.1.0, *)
final class EndpointFlow: CustomDebugStringConvertible {

/// State used to emit logs on the data path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ internal import Logging
internal import os
#endif

@available(Network 0.1.0, *)
struct EndpointFlowPrivateStorage {
func handleStateChange(_ state: EndpointFlow.State) {}
mutating func initForReuse(_ flow: EndpointFlow) {}
}

@available(Network 0.1.0, *)
extension EndpointFlow {

internal func startOnQueue() throws(NetworkError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ internal import Logging
internal import os
#endif

@available(Network 0.1.0, *)
protocol AbstractEndpointFlowProtocol: InboundDataHandler, LoggableProtocol {
func teardown()
}

@available(Network 0.1.0, *)
class EndpointFlowProtocol<LinkageType: InboundDataLinkage>: ProtocolInstanceContainer, AbstractEndpointFlowProtocol {
typealias LowerProtocol = LinkageType.PairedLinkage

Expand Down Expand Up @@ -247,6 +249,7 @@ class EndpointFlowProtocol<LinkageType: InboundDataLinkage>: ProtocolInstanceCon
}
}

@available(Network 0.1.0, *)
final class DatagramEndpointFlowProtocol: EndpointFlowProtocol<InboundDatagramLinkage>, InboundDatagramHandler {

override var reference: ProtocolInstanceReference { ProtocolInstanceReference(datagramEndpointFlow: self) }
Expand Down Expand Up @@ -375,6 +378,7 @@ final class DatagramEndpointFlowProtocol: EndpointFlowProtocol<InboundDatagramLi
}
}

@available(Network 0.1.0, *)
final class StreamEndpointFlowProtocol: EndpointFlowProtocol<InboundStreamLinkage>, InboundStreamHandler {

override var reference: ProtocolInstanceReference { ProtocolInstanceReference(streamEndpointFlow: self) }
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/EndpointFlow/ReadRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//

@available(Network 0.1.0, *)
struct ReadRequest {
let minimumBytes: Int
let maximumBytes: Int
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/EndpointFlow/WriteRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal import Logging
internal import os
#endif

@available(Network 0.1.0, *)
struct WriteRequest: ~Copyable {
var frame: Frame
let completion: (@Sendable (Result<Void, NetworkError>) -> Void)?
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftNetwork/Parameters/Parameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ public struct Parameters: Hashable, CustomStringConvertible {

// MARK: - Description

@available(Network 0.1.0, *)
extension Parameters {
public var description: String {
#if !NETWORK_EMBEDDED
Expand Down Expand Up @@ -880,6 +881,7 @@ extension Parameters {

// MARK: - Accessors

@available(Network 0.1.0, *)
extension Parameters {
var processUUID: SystemUUID {
get { pathParameters.processPathValue.processUUID }
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftNetwork/Parameters/PathParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ internal import Logging
internal import os
#endif

@available(Network 0.1.0, *)
struct PathParameters: Hashable, CustomStringConvertible {
struct ProcessPathValue: Hashable {
// Parameters that influence path selection for process delegation, by value, that
Expand Down Expand Up @@ -364,6 +365,7 @@ struct PathParameters: Hashable, CustomStringConvertible {
}

// MARK: - Copying and comparing
@available(Network 0.1.0, *)
extension PathParameters {
init(deepCopy other: PathParameters) {
self = other
Expand Down Expand Up @@ -451,6 +453,7 @@ extension PathParameters {
}

// MARK: - Description and logging
@available(Network 0.1.0, *)
extension PathParameters {
var description: String {
#if !NETWORK_EMBEDDED
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/Parameters/ProtocolTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import BasicContainers
internal import DequeModule
#endif

@available(Network 0.1.0, *)
struct ProtocolTransform: Hashable {
var transformStack: ProtocolStack?
var trafficClass: UInt32?
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftNetwork/Path/Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ public struct Interface: Sendable, Hashable, CustomStringConvertible {
}

#if !NETWORK_EMBEDDED
@available(Network 0.1.0, *)
extension Interface: Codable {
enum CodingKeys: String, CodingKey {
case name
Expand Down Expand Up @@ -518,6 +519,7 @@ extension Interface: Codable {
}
}

@available(Network 0.1.0, *)
extension InterfaceType: Codable {
enum CodingKeys: String, CodingKey {
case value
Expand All @@ -535,6 +537,7 @@ extension InterfaceType: Codable {
}
}

@available(Network 0.1.0, *)
extension InterfaceSubtype: Codable {
enum CodingKeys: String, CodingKey {
case value
Expand Down
6 changes: 6 additions & 0 deletions Sources/SwiftNetwork/Protocols/BottomProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ where UpperProtocol == InboundDatagramLinkage {

// MARK: - Bottom Protocol Implementation Details

@available(Network 0.1.0, *)
extension BottomProtocolHandler where Self: ~Copyable {
var asLower: UpperProtocol.PairedLinkage { .init(reference: reference) }

Expand Down Expand Up @@ -256,6 +257,7 @@ extension BottomProtocolHandler where Self: ~Copyable {
}

// Default implementations, to be overridden as necessary
@available(Network 0.1.0, *)
extension BottomProtocolHandler where Self: ~Copyable {
public func setup(
remote: Endpoint?,
Expand All @@ -281,6 +283,7 @@ extension BottomProtocolHandler where Self: ~Copyable {
#endif
}

@available(Network 0.1.0, *)
extension BottomProtocolHandler where Self: ~Copyable, UpperProtocol == InboundDatagramLinkage {
public mutating func attachUpperDatagramProtocol(
_ from: ProtocolInstanceReference,
Expand All @@ -305,6 +308,7 @@ extension BottomProtocolHandler where Self: ~Copyable, UpperProtocol == InboundD
}
}

@available(Network 0.1.0, *)
extension BottomProtocolHandler where Self: ~Copyable, UpperProtocol == InboundStreamLinkage {
public mutating func attachUpperStreamProtocol(
_ from: ProtocolInstanceReference,
Expand All @@ -329,6 +333,7 @@ extension BottomProtocolHandler where Self: ~Copyable, UpperProtocol == InboundS
}
}

@available(Network 0.1.0, *)
extension BottomDatagramProtocol where Self: ~Copyable {
public mutating func receiveDatagrams(
_ from: ProtocolInstanceReference,
Expand Down Expand Up @@ -366,6 +371,7 @@ extension BottomDatagramProtocol where Self: ~Copyable {
}
}

@available(Network 0.1.0, *)
extension BottomStreamProtocol where Self: ~Copyable {
public mutating func receiveStreamData(
_ from: ProtocolInstanceReference,
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftNetwork/Protocols/Checksum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum ChecksumError: Error {
case invalidBuffer
}

@available(Network 0.1.0, *)
extension IPv6Address {
func checksum() -> UInt32 {
let address = self.addressValue
Expand All @@ -66,6 +67,7 @@ extension IPv6Address {
}
}

@available(Network 0.1.0, *)
struct Checksum: ~Copyable {

// Compute IPv6 pseudo-header checksum
Expand Down Expand Up @@ -104,6 +106,7 @@ struct Checksum: ~Copyable {
}
}

@available(Network 0.1.0, *)
extension Frame {
func checksum16(offset: Int, length: Int) throws(ChecksumError) -> UInt16 {
let frameLength = self.unclaimedLength
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftNetwork/Protocols/CustomIPProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public struct CustomIPProtocol: NetworkProtocol {
}
}

@available(Network 0.1.0, *)
extension ProtocolOptions<CustomIPProtocol> {
var ipProtocolNumber: UInt8 {
get { perProtocolOptions!.ipProtocolNumber }
Expand Down
Loading
Loading