DistributedTargetInvocationEncoder

    Used to encode an invocation of a distributed target (method or computed property).

    iOS
    16.0+
    macOS
    13.0+
    tvOS
    16.0+
    watchOS
    9.0+
    protocol DistributedTargetInvocationEncoder<SerializationRequirement>
    Browse conforming types

    Forming an invocation

    On the sending-side an instance of an invocation is constructed by the runtime, and calls to: recordGenericSubstitution, recordArgument, recordReturnType, recordErrorType, and finally doneRecording are made (in this order).

    If the return type of the target is Void the recordReturnType is not invoked.

    If the error type thrown by the target is not defined the recordErrorType is not invoked.

    An invocation implementation may decide to perform serialization right-away in the record... invocations, or it may choose to delay doing so until the invocation is passed to the remoteCall. This decision largely depends on if serialization is allowed to happen on the caller’s task, and if any smarter encoding can be used once all parameter calls have been recorded (e.g. it may be possible to run-length encode values of certain types etc.)

    Once encoded, the system should use some underlying transport mechanism to send the bytes serialized by the invocation to the remote peer.

    Decoding an invocation

    Since every actor system is going to deal with a concrete invocation type, they may implement decoding them whichever way is most optimal for the given system.

    Once decided, the invocation must be passed to executeDistributedTarget which will decode the substitutions, argument values, return and error types (in that order).

    Note that the decoding will be provided the specific types that the sending side used to preform the call, so decoding can rely on simply invoking e.g. Codable (if that is the SerializationRequirement) decoding entry points on the provided types.

    Requirements

    Type members

    Instance members