From 6654e801833d5dab3c04af065646ba727f9542e9 Mon Sep 17 00:00:00 2001 From: Vamsi Madduluri Date: Mon, 2 Dec 2024 02:29:40 +0530 Subject: [PATCH] Add Sendable Conformance to Field and Reference Types (#353) * Add Sendable conformance to Field property wrapper Makes the Field property wrapper Sendable-compliant to better support concurrent operations and Swift's actor isolation system. * fix: make Field property wrapper conditionally Sendable - Remove direct Sendable conformance from Field struct - Add conditional Sendable conformance via extension where C: Sendable * fix: add Sendable conformance to Reference struct --- Sources/Meow/KeyPathModel/KeyPathModels.swift | 3 +++ Sources/Meow/Reference.swift | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Meow/KeyPathModel/KeyPathModels.swift b/Sources/Meow/KeyPathModel/KeyPathModels.swift index 23192a6a..23c57f90 100644 --- a/Sources/Meow/KeyPathModel/KeyPathModels.swift +++ b/Sources/Meow/KeyPathModel/KeyPathModels.swift @@ -361,6 +361,9 @@ public struct Field: Codable, _QueryableFieldRepresentable { } } +// Add conditional Sendable conformance +extension Field: Sendable where C: Sendable {} + extension Field: Equatable where C: Equatable { public static func ==(lhs: Self, rhs: Self) -> Bool { lhs.wrappedValue == rhs.wrappedValue diff --git a/Sources/Meow/Reference.swift b/Sources/Meow/Reference.swift index 8a2c61b6..d4d4be2c 100644 --- a/Sources/Meow/Reference.swift +++ b/Sources/Meow/Reference.swift @@ -13,7 +13,7 @@ import NIO /// let post: Post = try await postRef.resolve(in: req.meow) /// return post /// } -public struct Reference: Resolvable, Hashable, PrimitiveEncodable { +public struct Reference: Resolvable, Hashable, PrimitiveEncodable, Sendable where M.Identifier: Sendable { /// The referenced id public let reference: M.Identifier