Skip to content

Commit 6654e80

Browse files
authored
Add Sendable Conformance to Field and Reference Types (#353)
* Add Sendable conformance to Field property wrapper Makes the Field<C> 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
1 parent 807553c commit 6654e80

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Sources/Meow/KeyPathModel/KeyPathModels.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ public struct Field<C: Codable>: Codable, _QueryableFieldRepresentable {
361361
}
362362
}
363363

364+
// Add conditional Sendable conformance
365+
extension Field: Sendable where C: Sendable {}
366+
364367
extension Field: Equatable where C: Equatable {
365368
public static func ==(lhs: Self, rhs: Self) -> Bool {
366369
lhs.wrappedValue == rhs.wrappedValue

Sources/Meow/Reference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import NIO
1313
/// let post: Post = try await postRef.resolve(in: req.meow)
1414
/// return post
1515
/// }
16-
public struct Reference<M: ReadableModel>: Resolvable, Hashable, PrimitiveEncodable {
16+
public struct Reference<M: ReadableModel>: Resolvable, Hashable, PrimitiveEncodable, Sendable where M.Identifier: Sendable {
1717
/// The referenced id
1818
public let reference: M.Identifier
1919

0 commit comments

Comments
 (0)