Protocol a distributed invocation execution’s result handler.
An instance conforming to this type must be passed when invoking
executeDistributedTarget(on:target:invocationDecoder:handler:) while handling an incoming distributed call.
The handler will then be invoked with the return value (or error) that the invoked target returned (or threw).
Similar to the
DistributedActorSystem and its
remoteCallVoid protocol requirements, the
DistributedTargetInvocationResultHandler contains a method which is not possible to express in source due to advanced use of generics combined with associated types. Specifically, the
onReturn method is not expressed in source as protocol requirement, but will be treated by the compiler as-if they were.
In addition to the compiler offering compile errors if this witnesses is missing in an adopting type, we present its signature here for reference:
/// Ad-hoc protocol requirement /// /// Invoked when the distributed target execution returns successfully. /// The `value` is the return value of the executed distributed invocation target. func onReturn<Success: SerializationRequirement>(value: Success) async throws
The serialization requirement that the value passed to
onReturnis required to conform to.
) async throws
Invoked when the distributed target execution of a
Voidreturning function has completed successfully.
func onThrow<Err>(error: Err
) async throws
Invoked when the distributed target execution of a target has thrown an error.