<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Distributed/DistributedTargetInvocationResultHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Distributed"
    ],
    "preciseIdentifier" : "s:11Distributed0A29TargetInvocationResultHandlerP"
  },
  "title" : "DistributedTargetInvocationResultHandler"
}
-->

# DistributedTargetInvocationResultHandler

Protocol a distributed invocation execution’s result handler.

```
protocol DistributedTargetInvocationResultHandler<SerializationRequirement>
```

## Overview

An instance conforming to this type must be passed when invoking
[`executeDistributedTarget(on:target:invocationDecoder:handler:)`](/documentation/Distributed/DistributedActorSystem/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).

## Topics

### Associated Types

[`associatedtype SerializationRequirement`](/documentation/Distributed/DistributedTargetInvocationResultHandler/SerializationRequirement)

The serialization requirement that the value passed to `onReturn` is required to conform to.

### Instance Methods

[`func onReturn<Success>(value: Success) async throws`](/documentation/Distributed/DistributedTargetInvocationResultHandler/onReturn(value:))

Invoked when the distributed target execution returns successfully.
The `value` is the return value of the executed distributed invocation target.

[`func onReturnVoid() async throws`](/documentation/Distributed/DistributedTargetInvocationResultHandler/onReturnVoid())

Invoked when the distributed target execution of a `Void` returning
function has completed successfully.

[`func onThrow<Err>(error: Err) async throws`](/documentation/Distributed/DistributedTargetInvocationResultHandler/onThrow(error:))

Invoked when the distributed target execution of a target has thrown an error.

## Relationships

### Conforming Types

[`LocalTestingInvocationResultHandler`](/documentation/Distributed/LocalTestingInvocationResultHandler)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)