@@ -849,6 +849,27 @@ public struct RemoteCallArgument<Value> {
849
849
/// /// performs the actual distributed (local) instance method invocation.
850
850
/// mutating func decodeNextArgument<Argument: SerializationRequirement>() throws -> Argument
851
851
/// ```
852
+ ///
853
+ /// ### Decoding DistributedActor arguments using Codable
854
+ /// When using the actor system's ``ActorID`` is ``Codable``, every distributed actor using that system
855
+ /// is also implicitly ``Codable`` (see ``DistributedActorSystem``). Such distributed actors are encoded
856
+ /// as their ``ActorID`` stored in a ``Encoder/singleValueContainer``. Since ``Codable`` is being used
857
+ /// by this such system, it means that the ``decodeNextArgument`` method will be using ``Decoder`` to
858
+ /// decode the incoming values, some of which may be distributed actors.
859
+ ///
860
+ /// In order for a distributed actor's ``Decodable/init(from:)`` to be able to return an existing instance,
861
+ /// i.e. when the being-decoded ``ActorID`` actually references a locally hosted distributed actor, that the
862
+ /// current actor system can return from `resolve(id:as:)`, an actor system must be provided to the ``Decoder``.
863
+ /// This is done by setting the actor system the decoding is performed for, on the decoder's `userInfo`, as follows:
864
+ ///
865
+ /// ```
866
+ /// mutating func decodeNextArgument<Argument: SerializationRequirement>() throws -> Argument {
867
+ /// let argumentData: Data = /// ...
868
+ /// // ...
869
+ /// decoder.userInfo[.actorSystemKey] = self.actorSystem
870
+ /// return try Argument.decode(
871
+ /// }
872
+ // ```
852
873
@available ( SwiftStdlib 5 . 7 , * )
853
874
public protocol DistributedTargetInvocationDecoder {
854
875
/// The serialization requirement that the types passed to `decodeNextArgument` are required to conform to.
0 commit comments