From 09ddad1f4ce88252aed82f9884bc4bbfce33b635 Mon Sep 17 00:00:00 2001 From: damien-nd Date: Tue, 2 Jan 2024 14:09:05 +0100 Subject: [PATCH] [picta/feat] Add Sendable and StrictConcurrency feature (#1) --- Package.swift | 8 +++++--- Sources/Spyder/API+Types.swift | 4 ++-- Sources/Spyder/Builders/PropertyWrappers.swift | 10 +++++----- Sources/Spyder/Builders/URLRequestBuilder.swift | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Package.swift b/Package.swift index a198df1..19ad892 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.7 +// swift-tools-version: 5.9 import PackageDescription @@ -18,11 +18,13 @@ let package = Package( targets: [ .target( name: "Spyder", - dependencies: [] + dependencies: [], + swiftSettings: [.enableExperimentalFeature("StrictConcurrency")] ), .testTarget( name: "SpyderTests", - dependencies: ["Spyder"] + dependencies: ["Spyder"], + swiftSettings: [.enableExperimentalFeature("StrictConcurrency")] ) ] ) diff --git a/Sources/Spyder/API+Types.swift b/Sources/Spyder/API+Types.swift index 8af4f37..e6a0c08 100644 --- a/Sources/Spyder/API+Types.swift +++ b/Sources/Spyder/API+Types.swift @@ -4,7 +4,7 @@ public enum HTTPMethod: String { case delete, get, post, put } -public struct HTTPResponse: Equatable { +public struct HTTPResponse: Sendable, Equatable { public let statusCode: Int public let headers: [Header] public let data: Data @@ -16,7 +16,7 @@ public struct HTTPResponse: Equatable { } } -public struct Header: Equatable, Hashable { +public struct Header: Sendable, Equatable, Hashable { public let name: String public let value: String diff --git a/Sources/Spyder/Builders/PropertyWrappers.swift b/Sources/Spyder/Builders/PropertyWrappers.swift index 863f021..e5f1aa9 100644 --- a/Sources/Spyder/Builders/PropertyWrappers.swift +++ b/Sources/Spyder/Builders/PropertyWrappers.swift @@ -1,5 +1,5 @@ @propertyWrapper -public struct RequestHeader { +public struct RequestHeader: Sendable { let name: String public var wrappedValue = "" @@ -9,7 +9,7 @@ public struct RequestHeader { } @propertyWrapper -public struct PathArgument { +public struct PathArgument: Sendable { let name: String public var wrappedValue = "" @@ -19,7 +19,7 @@ public struct PathArgument { } @propertyWrapper -public struct QueryArgument { +public struct QueryArgument: Sendable { let name: String public var wrappedValue = "" @@ -29,7 +29,7 @@ public struct QueryArgument { } @propertyWrapper -public struct OptionalQueryArgument { +public struct OptionalQueryArgument: Sendable { let name: String public var wrappedValue: String? = .none @@ -39,7 +39,7 @@ public struct OptionalQueryArgument { } @propertyWrapper -public struct Body { +public struct Body: Sendable { public var wrappedValue: any Encodable public init(wrappedValue: any Encodable) { diff --git a/Sources/Spyder/Builders/URLRequestBuilder.swift b/Sources/Spyder/Builders/URLRequestBuilder.swift index 0703161..06f6294 100644 --- a/Sources/Spyder/Builders/URLRequestBuilder.swift +++ b/Sources/Spyder/Builders/URLRequestBuilder.swift @@ -3,7 +3,7 @@ import Foundation import FoundationNetworking #endif -public protocol URLRequestBuilder { +public protocol URLRequestBuilder: Sendable { static var method: HTTPMethod { get } static var path: String { get } }