Skip to content

Commit a2caaa3

Browse files
committed
[Distributed] Promote SerializationRequirement as a primary associated type for encoder/decoder/result
1 parent cdc9a01 commit a2caaa3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,18 @@ public protocol DistributedActorSystem<SerializationRequirement>: Sendable {
261261

262262
/// Type of ``DistributedTargetInvocationEncoder`` that should be used when the Swift runtime needs to encode
263263
/// a distributed target call into an encoder, before passing it off to `remoteCall(...)`.
264-
associatedtype InvocationEncoder: DistributedTargetInvocationEncoder
264+
associatedtype InvocationEncoder: DistributedTargetInvocationEncoder<SerializationRequirement>
265265
/// Type of ``DistributedTargetInvocationDecoder`` that should be used when decoding invocations during
266266
/// ``executeDistributedTarget(on:target:invocationDecoder:handler:)`` calls.
267-
associatedtype InvocationDecoder: DistributedTargetInvocationDecoder
267+
associatedtype InvocationDecoder: DistributedTargetInvocationDecoder<SerializationRequirement>
268268

269269
/// The type of the result handler which will be offered the results
270270
/// returned by a distributed function invocation called via
271271
/// ``executeDistributedTarget(on:target:invocationDecoder:handler:)``.
272-
associatedtype ResultHandler: DistributedTargetInvocationResultHandler
272+
associatedtype ResultHandler: DistributedTargetInvocationResultHandler<SerializationRequirement>
273273

274274
/// The serialization requirement that will be applied to all distributed targets used with this system.
275275
associatedtype SerializationRequirement // TODO: constrain SerializationRequirement in type-system to only be ok with protocol or class here
276-
where SerializationRequirement == InvocationEncoder.SerializationRequirement,
277-
SerializationRequirement == InvocationDecoder.SerializationRequirement,
278-
SerializationRequirement == ResultHandler.SerializationRequirement
279276

280277
// ==== ---------------------------------------------------------------------
281278
// - MARK: Resolving actors by identity
@@ -724,7 +721,7 @@ func _executeDistributedTarget<D: DistributedTargetInvocationDecoder, DA: Distri
724721
/// so decoding can rely on simply invoking e.g. `Codable` (if that is the `SerializationRequirement`) decoding
725722
/// entry points on the provided types.
726723
@available(SwiftStdlib 5.7, *)
727-
public protocol DistributedTargetInvocationEncoder {
724+
public protocol DistributedTargetInvocationEncoder<SerializationRequirement> {
728725
/// The serialization requirement that the types passed to `recordArgument` and `recordReturnType` are required to conform to.
729726
associatedtype SerializationRequirement
730727

@@ -861,7 +858,7 @@ public struct RemoteCallArgument<Value> {
861858
/// }
862859
/// ```
863860
@available(SwiftStdlib 5.7, *)
864-
public protocol DistributedTargetInvocationDecoder {
861+
public protocol DistributedTargetInvocationDecoder<SerializationRequirement> {
865862
/// The serialization requirement that the types passed to `decodeNextArgument` are required to conform to.
866863
/// The type returned by `decodeReturnType` is also expected to conform to this associated type requirement.
867864
associatedtype SerializationRequirement
@@ -928,7 +925,7 @@ public protocol DistributedTargetInvocationDecoder {
928925
/// func onReturn<Success: SerializationRequirement>(value: Success) async throws
929926
/// ```
930927
@available(SwiftStdlib 5.7, *)
931-
public protocol DistributedTargetInvocationResultHandler {
928+
public protocol DistributedTargetInvocationResultHandler<SerializationRequirement> {
932929
/// The serialization requirement that the value passed to `onReturn` is required to conform to.
933930
associatedtype SerializationRequirement
934931

0 commit comments

Comments
 (0)