Bidirectional communication and streams for plugins (#11911)

This commit is contained in:
Devyn Cairns
2024-02-25 14:32:50 -08:00
committed by GitHub
parent 461f69ac5d
commit 88f1f386bb
47 changed files with 8025 additions and 1496 deletions

View File

@ -6,7 +6,7 @@ use crate::engine::Command;
use crate::{BlockId, Category, Flag, PositionalArg, SyntaxShape, Type};
/// A simple wrapper for Signature that includes examples.
#[derive(Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginSignature {
pub sig: Signature,
pub examples: Vec<PluginExample>,

View File

@ -774,6 +774,54 @@ pub enum ShellError {
#[diagnostic(code(nu::shell::plugin_failed_to_decode))]
PluginFailedToDecode { msg: String },
/// A custom value cannot be sent to the given plugin.
///
/// ## Resolution
///
/// Custom values can only be used with the plugin they came from. Use a command from that
/// plugin instead.
#[error("Custom value `{name}` cannot be sent to plugin")]
#[diagnostic(code(nu::shell::custom_value_incorrect_for_plugin))]
CustomValueIncorrectForPlugin {
name: String,
#[label("the `{dest_plugin}` plugin does not support this kind of value")]
span: Span,
dest_plugin: String,
#[help("this value came from the `{}` plugin")]
src_plugin: Option<String>,
},
/// The plugin failed to encode a custom value.
///
/// ## Resolution
///
/// This is likely a bug with the plugin itself. The plugin may have tried to send a custom
/// value that is not serializable.
#[error("Custom value failed to encode")]
#[diagnostic(code(nu::shell::custom_value_failed_to_encode))]
CustomValueFailedToEncode {
msg: String,
#[label("{msg}")]
span: Span,
},
/// The plugin failed to encode a custom value.
///
/// ## Resolution
///
/// This may be a bug within the plugin, or the plugin may have been updated in between the
/// creation of the custom value and its use.
#[error("Custom value failed to decode")]
#[diagnostic(code(nu::shell::custom_value_failed_to_decode))]
#[diagnostic(help(
"the plugin may have been updated and no longer support this custom value"
))]
CustomValueFailedToDecode {
msg: String,
#[label("{msg}")]
span: Span,
},
/// I/O operation interrupted.
///
/// ## Resolution

View File

@ -164,7 +164,6 @@ pub enum Value {
#[serde(rename = "span")]
internal_span: Span,
},
#[serde(skip_serializing)]
CustomValue {
val: Box<dyn CustomValue>,
// note: spans are being refactored out of Value