Skip to content

Commit 77496a1

Browse files
authored
Fix plugin reference to Value::Custom rename (#1316)
See nushell/nushell#12309
1 parent 1d1273f commit 77496a1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

contributor-book/plugin_protocol_reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Example (comparing two `version` custom values):
288288
},
289289
{
290290
"PartialCmp": {
291-
"CustomValue": {
291+
"Custom": {
292292
"val": {
293293
"type": "PluginCustomValue",
294294
"name": "version",
@@ -1102,7 +1102,7 @@ Example:
11021102

11031103
```json
11041104
{
1105-
"CustomValue": {
1105+
"Custom": {
11061106
"val": {
11071107
"type": "PluginCustomValue",
11081108
"name": "database",

contributor-book/plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ At present, the closures can only refer to values that would be valid to send to
530530

531531
Plugins can create custom values that embed plugin-specific data within the engine. In Rust, this data is automatically serialized using [bincode](https://crates.io/crates/bincode), so all you need to do is implement the [`CustomValue`](https://docs.rs/nu-protocol/latest/nu_protocol/trait.CustomValue.html) trait on a type that has `Serialize` and `Deserialize` implementations compatible with bincode. This includes any attributes that would cause a dependency on field names or field presence, such as `#[serde(skip_serializing_if = "...")]` or `#[serde(untagged)]`. We use the [typetag](https://crates.io/crates/typetag) crate to reconstruct the correct custom value type.
532532

533-
To embed the custom value in a `Value`, use [`Value::custom_value()`](https://docs.rs/nu-protocol/latest/nu_protocol/enum.Value.html#method.custom_value). A minimal example:
533+
To embed the custom value in a `Value`, use [`Value::custom()`](https://docs.rs/nu-protocol/latest/nu_protocol/enum.Value.html#method.custom_value). A minimal example:
534534

535535
```rust
536536
use nu_protocol::{CustomValue, ShellError, Span, Value, record};
@@ -583,7 +583,7 @@ impl CustomValue for Animal {
583583
}
584584

585585
// Use the custom value
586-
Value::custom_value(Box::new(Animal::Dog {
586+
Value::custom(Box::new(Animal::Dog {
587587
name: "Rex".into(),
588588
woof: true,
589589
}), call.head)

0 commit comments

Comments
 (0)