Rename Value::CustomValue to Value::Custom (#12309)

# Description
The second `Value` is redundant and will consume five extra bytes on
each transmission of a custom value to/from a plugin.

# User-Facing Changes
This is a breaking change to the plugin protocol.

The [example in the protocol
reference](https://www.nushell.sh/contributor-book/plugin_protocol_reference.html#value)
becomes

```json
{
  "Custom": {
    "val": {
      "type": "PluginCustomValue",
      "name": "database",
      "data": [36, 190, 127, 40, 12, 3, 46, 83],
      "notify_on_drop": true
    },
    "span": {
      "start": 320,
      "end": 340
    }
  }
}
```

instead of 

```json
{
  "CustomValue": {
    ...
  }
}
```


# After Submitting
Update plugin protocol reference
This commit is contained in:
Stefan Holderbach
2024-03-27 22:10:56 +01:00
committed by GitHub
parent dfbbacfdf8
commit b19da158d5
48 changed files with 144 additions and 148 deletions

View File

@ -115,7 +115,7 @@ fn to_string_tagged_value(
| Value::Int { .. }
| Value::Duration { .. }
| Value::Binary { .. }
| Value::CustomValue { .. }
| Value::Custom { .. }
| Value::Filesize { .. }
| Value::CellPath { .. }
| Value::Float { .. } => Ok(v.clone().to_abbreviated_string(config)),

View File

@ -139,7 +139,7 @@ pub fn value_to_json_value(v: &Value) -> Result<nu_json::Value, ShellError> {
let collected = val.collect()?;
value_to_json_value(&collected)?
}
Value::CustomValue { val, .. } => {
Value::Custom { val, .. } => {
let collected = val.to_base_value(span)?;
value_to_json_value(&collected)?
}

View File

@ -158,7 +158,7 @@ pub fn value_to_string(
msg_span: span,
input_span: v.span(),
}),
Value::CustomValue { .. } => Err(ShellError::UnsupportedInput {
Value::Custom { .. } => Err(ShellError::UnsupportedInput {
msg: "custom values are currently not nuon-compatible".to_string(),
input: "value originates from here".into(),
msg_span: span,

View File

@ -147,7 +147,7 @@ fn local_into_string(value: Value, separator: &str, config: &Config) -> String {
Value::CellPath { val, .. } => val.to_string(),
// If we fail to collapse the custom value, just print <{type_name}> - failure is not
// that critical here
Value::CustomValue { val, .. } => val
Value::Custom { val, .. } => val
.to_base_value(span)
.map(|val| local_into_string(val, separator, config))
.unwrap_or_else(|_| format!("<{}>", val.type_name())),

View File

@ -93,7 +93,7 @@ fn helper(engine_state: &EngineState, v: &Value) -> Result<toml::Value, ShellErr
})
.collect::<Result<Vec<toml::Value>, ShellError>>()?,
),
Value::CustomValue { .. } => toml::Value::String("<Custom Value>".to_string()),
Value::Custom { .. } => toml::Value::String("<Custom Value>".to_string()),
})
}

View File

@ -95,7 +95,7 @@ pub fn value_to_yaml_value(v: &Value) -> Result<serde_yaml::Value, ShellError> {
})
.collect::<Result<Vec<serde_yaml::Value>, ShellError>>()?,
),
Value::CustomValue { .. } => serde_yaml::Value::Null,
Value::Custom { .. } => serde_yaml::Value::Null,
})
}