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
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-collections.git", .upToNextMinor(from: "1.6.0")),
.package(url: "https://github.com/apple/swift-collections.git", .upToNextMinor(from: "1.7.1")),
.package(url: "https://github.com/apple/swift-crypto.git", from: "5.0.0-beta.1"),
.package(url: "https://github.com/apple/swift-tls.git", .upToNextMinor(from: "0.1.2")),
],
targets: [
.target(
name: "SwiftNetwork",
dependencies: [
.product(name: "Logging", package: "swift-log", condition: .when(platforms: [.linux])),
.target(name: "SwiftNetworkLinuxShim", condition: .when(platforms: [.linux])),
.product(name: "Logging", package: "swift-log", condition: .when(platforms: [.linux, .android])),
.target(name: "SwiftNetworkLinuxShim", condition: .when(platforms: [.linux, .android])),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "BasicContainers", package: "swift-collections"),
.product(name: "Crypto", package: "swift-crypto"),
Expand All @@ -138,7 +138,7 @@ let package = Package(
name: "SwiftNetworkTestHarness",
dependencies: [
"SwiftNetwork",
.product(name: "Logging", package: "swift-log", condition: .when(platforms: [.linux])),
.product(name: "Logging", package: "swift-log", condition: .when(platforms: [.linux, .android])),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "BasicContainers", package: "swift-collections"),
],
Expand All @@ -151,7 +151,7 @@ let package = Package(
"SwiftNetworkTestHarness",
.product(name: "SwiftTLS", package: "swift-tls"),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "Logging", package: "swift-log", condition: .when(platforms: [.linux])),
.product(name: "Logging", package: "swift-log", condition: .when(platforms: [.linux, .android])),
],
swiftSettings: availabilityMacros + settings
),
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Connection/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import BasicContainers
internal import DequeModule
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Context/NetworkContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import Dispatch
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Endpoint/AddressEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
6 changes: 5 additions & 1 deletion Sources/SwiftNetwork/Endpoint/NetlinkAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
internal import SwiftNetworkLinuxShim
#elseif canImport(Glibc)
import Glibc
internal import Logging
internal import SwiftNetworkLinuxShim
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/EndpointFlow/EndpointFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import BasicContainers
internal import DequeModule
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/EndpointFlow/WriteRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
internal import SwiftSystem
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Parameters/Parameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import BasicContainers
internal import DequeModule
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Parameters/PathParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import BasicContainers
internal import DequeModule
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Path/Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Path/PathProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import BasicContainers
internal import DequeModule
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/BaseProtocolLinkages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
// `external` case, holding a class that speaks these same concrete types -- see
// `ExternalProtocolLinkages.swift`.

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/BottomProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/BridgeProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/Checksum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/CustomIPProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/CustomLinkProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/DemuxProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/Frame.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import BasicContainers
internal import DequeModule
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
13 changes: 12 additions & 1 deletion Sources/SwiftNetwork/Protocols/FrameArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public struct FrameArray: ~Copyable {
#if !NETWORK_EMBEDDED
@_lifetime(borrow self)
func bytes(at index: Int) -> RawSpan? {
frames[index].bytes
frames[index].bytes(borrowing: self)
}
#endif

Expand Down Expand Up @@ -299,6 +299,17 @@ public struct FrameArray: ~Copyable {
}
}

#if !NETWORK_EMBEDDED
@available(Network 0.1.0, *)
private extension Frame {
// Only use when this frame is borrowed from `owner`.
@_lifetime(borrow owner)
func bytes(borrowing owner: borrowing FrameArray) -> RawSpan? {
_overrideLifetime(self.bytes, borrowing: owner)
}
}
#endif

@_spi(ProtocolProvider)
@available(Network 0.1.0, *)
extension NetworkUniqueDeque where Element: ~Copyable {
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/IPProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
26 changes: 26 additions & 0 deletions Sources/SwiftNetwork/Protocols/InstanceIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,30 @@ public struct InstanceIdentifier: Hashable {
public var isNone: Bool {
eventStateIndex.isNone
}

/// Enters this instance's execution state from outside the stack.
///
/// Use this from a protocol implemented outside the framework when it holds its identifier
/// and context but no event context. The block receives the event context, which must be
/// threaded into any calls made to other protocols. If you already hold the event context,
/// call the `in:`-taking variant instead so the state isn't re-derived from the context.
public func fromExternal<R, E: Error>(
context: NetworkContext,
_ body: (inout NetworkContext.EventContext) throws(E) -> R
) throws(E) -> R {
try fromExternal(in: &context.eventContext, body)
}

/// Enters this instance's execution state from outside the stack.
///
/// Use this from a protocol implemented outside the framework when it holds its identifier
/// and context but no event context. The block receives the event context, which must be
/// threaded into any calls made to other protocols. If you already hold the event context,
/// call the `in:`-taking variant instead so the state isn't re-derived from the context.
public func fromExternal<R: ~Copyable, E: Error>(
context: NetworkContext,
_ body: (inout NetworkContext.EventContext) throws(E) -> R
) throws(E) -> R {
try fromExternal(in: &context.eventContext, body)
}
}
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/OneToOneProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftNetwork/Protocols/ProtocolEventManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import BasicContainers
internal import DequeModule
#endif

#if canImport(Glibc)
#if canImport(Android)
import Android
internal import Logging
#elseif canImport(Glibc)
import Glibc
internal import Logging
#elseif canImport(Musl)
Expand Down
Loading
Loading