Home Explore Blog CI



nushell

6th chunk of `contributor-book/plugin_protocol_reference.md`
0cae0591ae2233342b90065f7b2d6ce01224bb8ab383dbf40000000100000fc0
              "span": {
                "start": 560,
                "end": 566
              }
            }
          }
        }
      ]
    }
  ]
}
```

##### `Operation`

Returns the result of evaluating an [`Operator`](#operator) on this custom value with another value. The argument is a 2-tuple: (`operator`, `value`), where `operator` is a spanned [`Operator`](#operator) and `value` is a [`Value`](#value), which may be any value - not just the same custom value type. The response type is [`PipelineData`](#pipelinedata-plugin-call-response) or [`Error`](#error-plugin-call-response). The result **may** be another custom value. If the operation produces a stream, it will be consumed to a value.

Example:

```nu
$version + 7
```

```json
{
  "Call": [
    0,
    {
      "CustomValueOp": [
        {
          "item": {
            "name": "version",
            "data": [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0]
          },
          "span": {
            "start": 90,
            "end": 96
          }
        },
        {
          "Operation": [
            {
              "item": {
                "Math": "Plus"
              },
              "span": {
                "start": 180,
                "end": 181
              }
            },
            {
              "Int": {
                "val": 7,
                "span": {
                  "start": 183,
                  "end": 184
                }
              }
            }
          ]
        }
      ]
    }
  ]
}
```

##### `Dropped`

This op is used to notify the plugin that a [`PluginCustomValue`](#plugincustomvalue) that had `notify_on_drop` set to `true` was dropped in the engine - i.e., all copies of it have gone out of scope. For more information on exactly under what circumstances this is sent, see the [drop notification](plugins.md#drop-notification) section of the plugin reference. The response type is [`Empty` pipeline data](#empty-header-variant) or [`Error`](#error-plugin-call-response).

Example:

```json
{
  "Call": [
    0,
    {
      "CustomValueOp": [
        {
          "item": {
            "name": "handle",
            "data": [78, 60],
            "notify_on_drop": true
          },
          "span": {
            "start": 1820,
            "end": 1835
          }
        },
        "Dropped"
      ]
    }
  ]
}
```

### `EngineCallResponse`

A response to an [engine call](#enginecall) made by the plugin. The argument is a 2-tuple (array): (`engine_call_id`, `engine_call`)

The `engine_call_id` refers to the same number that the engine call being responded to originally contained. The plugin **must** send unique IDs for each engine call it makes. Like [`CallResponse`](#callresponse), there are multiple types of responses:

#### `Error` engine call response

A failure result. Contains a [`LabeledError`](#labelederror).

Example:

```json
{
  "EngineCallResponse": [
    0,
    {
      "Error": {
        "LabeledError": {
          "msg": "The connection closed.",
          "labels": [],
          "code": null,
          "url": null,
          "help": null,
          "inner": []
        }
      }
    }
  ]
}
```

#### `PipelineData` engine call response

A successful result with a Nu [`Value`](#value) or stream. The body is a [`PipelineDataHeader`](#pipelinedataheader).

Example:

```json
{
  "EngineCallResponse": [
    0,
    {
      "ListStream": {
        "id": 23,
        "span": {
          "start": 8081,
          "end": 8087
        }
      }
    }
  ]
}
```

#### `Config` engine call response

A successful result of a [`Config` engine call](#config-engine-call). The body is a [`Config`](#config).

Example:

```json
{
  "EngineCallResponse": [
    0,
    {
      "Config": {
        "external_completer": null,
        "filesize_metric": true,
        "table_mode": "Rounded",
        "table_move_header": false,
        ...
      }
    }
  ]
}
```

This example is abbreviated, as the [`Config`](#config) object is large and ever-changing.

#### `ValueMap` engine call response

Title: CustomValueOp Plugin Calls: `Operation` and `Dropped` & EngineCallResponse Details
Summary
This section details two more `CustomValueOp` plugin calls: `Operation` and `Dropped`, along with `EngineCallResponse` details. `Operation` evaluates an operator on a custom value with another value, returning `PipelineData` or `Error`. `Dropped` notifies the plugin when a `PluginCustomValue` with `notify_on_drop` set to true is dropped. It then covers various `EngineCallResponse` types, including `Error` (a failure result with a `LabeledError`), `PipelineData` (a successful result with a `Value` or stream), `Config` (a successful result of a `Config` engine call), and others. Examples and explanations are provided for each response type.