Skip to content

Commit

Permalink
Add Sendable Conformances (#90)
Browse files Browse the repository at this point in the history
* Add 5.9 manifest

* Bump minimum Swift version to 5.7

* Add Sendable annotations to most types
  • Loading branch information
0xTim authored Dec 18, 2023
1 parent cf2f6ad commit 12ee56f
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.4
// swift-tools-version:5.7
import PackageDescription

let package = Package(
Expand Down
33 changes: 33 additions & 0 deletions Package@swift-5.9.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "multipart-kit",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
],
products: [
.library(name: "MultipartKit", targets: ["MultipartKit"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.61.1"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.5")
],
targets: [
.target(
name: "MultipartKit",
dependencies: [
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOHTTP1", package: "swift-nio"),
.product(name: "Collections", package: "swift-collections")
],
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]),
.testTarget(
name: "MultipartKitTests",
dependencies: ["MultipartKit"],
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]),
]
)
4 changes: 2 additions & 2 deletions Sources/MultipartKit/FormDataDecoder/FormDataDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import NIOHTTP1
/// See [RFC#2388](https://tools.ietf.org/html/rfc2388) for more information about `multipart/form-data` encoding.
///
/// Seealso `MultipartParser` for more information about the `multipart` encoding.
public struct FormDataDecoder {
public struct FormDataDecoder: Sendable {

/// Maximum nesting depth to allow when decoding the input.
/// - 1 corresponds to a single value
Expand All @@ -15,7 +15,7 @@ public struct FormDataDecoder {
let nestingDepth: Int

/// Any contextual information set by the user for decoding.
public var userInfo: [CodingUserInfoKey: Any] = [:]
public var userInfo: [CodingUserInfoKey: Sendable] = [:]

/// Creates a new `FormDataDecoder`.
/// - Parameter nestingDepth: maximum allowed nesting depth of the decoded structure. Defaults to 8.
Expand Down
4 changes: 2 additions & 2 deletions Sources/MultipartKit/FormDataEncoder/FormDataEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import NIOCore
/// See [RFC#2388](https://tools.ietf.org/html/rfc2388) for more information about `multipart/form-data` encoding.
///
/// Seealso `MultipartParser` for more information about the `multipart` encoding.
public struct FormDataEncoder {
public struct FormDataEncoder: Sendable {

/// Any contextual information set by the user for encoding.
public var userInfo: [CodingUserInfoKey: Any] = [:]
public var userInfo: [CodingUserInfoKey: Sendable] = [:]

/// Creates a new `FormDataEncoder`.
public init() { }
Expand Down
4 changes: 2 additions & 2 deletions Sources/MultipartKit/MultipartFormData.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Collections
@preconcurrency import Collections

enum MultipartFormData: Equatable {
enum MultipartFormData: Equatable, Sendable {
typealias Keyed = OrderedDictionary<String, MultipartFormData>

case single(MultipartPart)
Expand Down
2 changes: 1 addition & 1 deletion Sources/MultipartKit/MultipartPart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import NIOHTTP1
import Foundation

/// A single part of a `multipart`-encoded message.
public struct MultipartPart: Equatable {
public struct MultipartPart: Equatable, Sendable {
/// The part's headers.
public var headers: HTTPHeaders

Expand Down
2 changes: 1 addition & 1 deletion Sources/MultipartKit/MultipartSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import NIOCore
/// Serializes `MultipartForm`s to `Data`.
///
/// See `MultipartParser` for more information about the multipart encoding.
public final class MultipartSerializer {
public final class MultipartSerializer: Sendable {

/// Creates a new `MultipartSerializer`.
public init() { }
Expand Down

0 comments on commit 12ee56f

Please sign in to comment.