nushell/crates/nu-protocol/src
Devyn Cairns 73f3c0b60b
Support for all custom value operations on plugin custom values (#12088)
# Description

Adds support for the following operations on plugin custom values, in
addition to `to_base_value` which was already present:

- `follow_path_int()`
- `follow_path_string()`
- `partial_cmp()`
- `operation()`
- `Drop` (notification, if opted into with
`CustomValue::notify_plugin_on_drop`)

There are additionally customizable methods within the `Plugin` and
`StreamingPlugin` traits for implementing these functions in a way that
requires access to the plugin state, as a registered handle model such
as might be used in a dataframes plugin would.

`Value::append` was also changed to handle custom values correctly.

# User-Facing Changes

- Signature of `CustomValue::follow_path_string` and
`CustomValue::follow_path_int` changed to give access to the span of the
custom value itself, useful for some errors.
- Plugins using custom values have to be recompiled because the engine
will try to do custom value operations that aren't supported
- Plugins can do more things 🎉 

# Tests + Formatting
Tests were added for all of the new custom values functionality.

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
- [ ] Document protocol reference `CustomValueOp` variants:
  - [ ] `FollowPathInt`
  - [ ] `FollowPathString`
  - [ ] `PartialCmp`
  - [ ] `Operation`
  - [ ] `Dropped`
- [ ] Document `notify_on_drop` optional field in `PluginCustomValue`
2024-03-12 10:37:08 +01:00
..
ast Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
config Keep plugins persistently running in the background (#12064) 2024-03-09 17:10:22 -06:00
debugger Debugger experiments (#11441) 2024-03-08 20:21:35 +02:00
engine Fix ignored clippy lints (#12160) 2024-03-11 19:46:04 +01:00
errors Remove outdated doccomment on EngineState (#12158) 2024-03-11 14:57:28 +00:00
pipeline_data Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
plugin Keep plugins persistently running in the background (#12064) 2024-03-09 17:10:22 -06:00
value Support for all custom value operations on plugin custom values (#12088) 2024-03-12 10:37:08 +01:00
alias.rs Refactor scope commands (#10023) 2023-08-17 11:58:38 +03:00
did_you_mean.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
eval_base.rs Debugger experiments (#11441) 2024-03-08 20:21:35 +02:00
eval_const.rs Debugger experiments (#11441) 2024-03-08 20:21:35 +02:00
example.rs Fix ignored clippy lints (#12160) 2024-03-11 19:46:04 +01:00
id.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
lev_distance.rs Suggest existing variables on not found (#8902) 2023-05-02 18:17:14 +03:00
lib.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
module.rs Error on use path item1 item2, if item1 is not a module (#11183) 2023-12-05 11:38:45 +01:00
signature.rs Replace debug_assert! with assert! in Signature::check_names (#11937) 2024-02-22 16:17:06 -06:00
span.rs Replace panics with errors in thread spawning (#12040) 2024-03-02 11:14:02 -06:00
syntax_shape.rs open, rm, umv, cp, rm and du: Don't globs if inputs are variables or string interpolation (#11886) 2024-02-23 09:17:09 +08:00
ty.rs Glob: don't allow implicit casting between glob and string (#11992) 2024-02-28 23:05:35 +08:00
util.rs Convert more ShellError variants to named fields (#11173) 2023-11-28 06:43:51 -06:00