Rust 1.85, edition=2024 (#15741)

This commit is contained in:
Jack Wright
2025-05-13 07:49:30 -07:00
committed by GitHub
parent 1a0986903f
commit c2ac8f730e
793 changed files with 4276 additions and 3687 deletions

View File

@ -2,7 +2,7 @@
authors = ["The Nushell Project Developers"]
description = "Functionality for running Nushell plugins from a Nushell engine"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-engine"
edition = "2021"
edition = "2024"
license = "MIT"
name = "nu-plugin-engine"
version = "0.104.1"
@ -35,4 +35,4 @@ local-socket = ["nu-plugin-core/local-socket"]
windows = { workspace = true, features = [
# For setting process creation flags
"Win32_System_Threading",
] }
] }

View File

@ -1,15 +1,16 @@
use crate::util::MutableCow;
use nu_engine::{get_eval_block_with_early_return, get_full_help, ClosureEvalOnce};
use nu_engine::{ClosureEvalOnce, get_eval_block_with_early_return, get_full_help};
use nu_plugin_protocol::EvaluatedCall;
use nu_protocol::{
Config, DeclId, IntoSpanned, OutDest, PipelineData, PluginIdentity, ShellError, Signals, Span,
Spanned, Value,
engine::{Call, Closure, EngineState, Redirection, Stack},
ir, Config, DeclId, IntoSpanned, OutDest, PipelineData, PluginIdentity, ShellError, Signals,
Span, Spanned, Value,
ir,
};
use std::{
borrow::Cow,
collections::HashMap,
sync::{atomic::AtomicU32, Arc},
sync::{Arc, atomic::AtomicU32},
};
/// Object safe trait for abstracting operations required of the plugin context.

View File

@ -1,6 +1,6 @@
use nu_engine::{command_prelude::*, get_eval_expression};
use nu_plugin_protocol::{CallInfo, EvaluatedCall};
use nu_protocol::{engine::CommandType, PluginIdentity, PluginSignature};
use nu_protocol::{PluginIdentity, PluginSignature, engine::CommandType};
use std::sync::Arc;
use crate::{GetPlugin, PluginExecutionCommandContext, PluginSource};

View File

@ -1,7 +1,7 @@
use crate::PersistentPlugin;
use nu_protocol::{PluginGcConfig, RegisteredPlugin};
use std::{
sync::{mpsc, Arc, Weak},
sync::{Arc, Weak, mpsc},
thread,
time::{Duration, Instant},
};

View File

@ -15,8 +15,8 @@ use nu_plugin_core::{
ServerCommunicationIo,
};
use nu_protocol::{
engine::StateWorkingSet, report_shell_error, PluginIdentity, PluginRegistryFile,
PluginRegistryItem, PluginRegistryItemData, RegisteredPlugin, ShellError, Span,
PluginIdentity, PluginRegistryFile, PluginRegistryItem, PluginRegistryItemData,
RegisteredPlugin, ShellError, Span, engine::StateWorkingSet, report_shell_error,
};
use crate::{

View File

@ -1,9 +1,9 @@
//! Interface used by the engine to communicate with the plugin.
use nu_plugin_core::{
util::{with_custom_values_in, Waitable, WaitableMut},
Interface, InterfaceManager, PipelineDataWriter, PluginRead, PluginWrite, StreamManager,
StreamManagerHandle,
util::{Waitable, WaitableMut, with_custom_values_in},
};
use nu_plugin_protocol::{
CallInfo, CustomValueOp, EngineCall, EngineCallId, EngineCallResponse, EvaluatedCall, Ordering,
@ -11,18 +11,18 @@ use nu_plugin_protocol::{
PluginOutput, ProtocolInfo, StreamId, StreamMessage,
};
use nu_protocol::{
ast::Operator, engine::Sequence, CustomValue, IntoSpanned, PipelineData, PluginMetadata,
PluginSignature, ShellError, SignalAction, Signals, Span, Spanned, Value,
CustomValue, IntoSpanned, PipelineData, PluginMetadata, PluginSignature, ShellError,
SignalAction, Signals, Span, Spanned, Value, ast::Operator, engine::Sequence,
};
use nu_utils::SharedCow;
use std::{
collections::{btree_map, BTreeMap},
sync::{mpsc, Arc, OnceLock},
collections::{BTreeMap, btree_map},
sync::{Arc, OnceLock, mpsc},
};
use crate::{
process::PluginProcess, PluginCustomValueWithSource, PluginExecutionContext, PluginGc,
PluginSource,
PluginCustomValueWithSource, PluginExecutionContext, PluginGc, PluginSource,
process::PluginProcess,
};
#[cfg(test)]

View File

@ -2,29 +2,28 @@ use super::{
Context, PluginCallState, PluginInterface, PluginInterfaceManager, ReceivedPluginCallMessage,
};
use crate::{
context::PluginExecutionBogusContext, interface::CurrentCallState,
plugin_custom_value_with_source::WithSource, test_util::*, PluginCustomValueWithSource,
PluginSource,
PluginCustomValueWithSource, PluginSource, context::PluginExecutionBogusContext,
interface::CurrentCallState, plugin_custom_value_with_source::WithSource, test_util::*,
};
use nu_engine::command_prelude::IoError;
use nu_plugin_core::{interface_test_util::TestCase, Interface, InterfaceManager};
use nu_plugin_core::{Interface, InterfaceManager, interface_test_util::TestCase};
use nu_plugin_protocol::{
test_util::{expected_test_custom_value, test_plugin_custom_value},
ByteStreamInfo, CallInfo, CustomValueOp, EngineCall, EngineCallResponse, EvaluatedCall,
ListStreamInfo, PipelineDataHeader, PluginCall, PluginCallId, PluginCallResponse,
PluginCustomValue, PluginInput, PluginOutput, Protocol, ProtocolInfo, StreamData,
StreamMessage,
test_util::{expected_test_custom_value, test_plugin_custom_value},
};
use nu_protocol::{
ast::{Math, Operator},
engine::Closure,
BlockId, ByteStreamType, CustomValue, DataSource, IntoInterruptiblePipelineData, IntoSpanned,
PipelineData, PipelineMetadata, PluginMetadata, PluginSignature, ShellError, Signals, Span,
Spanned, Value,
ast::{Math, Operator},
engine::Closure,
};
use serde::{Deserialize, Serialize};
use std::{
sync::{mpsc, Arc},
sync::{Arc, mpsc},
time::Duration,
};
@ -321,8 +320,8 @@ fn set_default_protocol_info(manager: &mut PluginInterfaceManager) -> Result<(),
}
#[test]
fn manager_consume_call_response_forwards_to_subscriber_with_pipeline_data(
) -> Result<(), ShellError> {
fn manager_consume_call_response_forwards_to_subscriber_with_pipeline_data()
-> Result<(), ShellError> {
let mut manager = TestCase::new().plugin("test");
set_default_protocol_info(&mut manager)?;
@ -545,8 +544,8 @@ fn manager_handle_engine_call_after_response_received() -> Result<(), ShellError
}
#[test]
fn manager_send_plugin_call_response_removes_context_only_if_no_streams_to_read(
) -> Result<(), ShellError> {
fn manager_send_plugin_call_response_removes_context_only_if_no_streams_to_read()
-> Result<(), ShellError> {
let mut manager = TestCase::new().plugin("test");
for n in [0, 1] {
@ -1244,27 +1243,31 @@ fn prepare_custom_value_verifies_source() {
let source = Arc::new(PluginSource::new_fake("test"));
let mut val: Box<dyn CustomValue> = Box::new(test_plugin_custom_value());
assert!(CurrentCallState::default()
.prepare_custom_value(
Spanned {
item: &mut val,
span,
},
&source
)
.is_err());
assert!(
CurrentCallState::default()
.prepare_custom_value(
Spanned {
item: &mut val,
span,
},
&source
)
.is_err()
);
let mut val: Box<dyn CustomValue> =
Box::new(test_plugin_custom_value().with_source(source.clone()));
assert!(CurrentCallState::default()
.prepare_custom_value(
Spanned {
item: &mut val,
span,
},
&source
)
.is_ok());
assert!(
CurrentCallState::default()
.prepare_custom_value(
Spanned {
item: &mut val,
span,
},
&source
)
.is_ok()
);
}
#[derive(Debug, Serialize, Deserialize)]

View File

@ -1,15 +1,15 @@
use crate::{
init::{create_command, make_plugin_interface},
PluginGc,
init::{create_command, make_plugin_interface},
};
use super::{PluginInterface, PluginSource};
use nu_plugin_core::CommunicationMode;
use nu_protocol::{
engine::{EngineState, Stack},
shell_error::io::IoError,
HandlerGuard, Handlers, PluginGcConfig, PluginIdentity, PluginMetadata, RegisteredPlugin,
ShellError,
engine::{EngineState, Stack},
shell_error::io::IoError,
};
use std::{
collections::HashMap,
@ -111,9 +111,11 @@ impl PersistentPlugin {
Some(PreferredCommunicationMode::Stdio)
)
{
log::warn!("{}: Trying again with stdio communication because mode {:?} failed with {result:?}",
log::warn!(
"{}: Trying again with stdio communication because mode {:?} failed with {result:?}",
self.identity.name(),
mutable.preferred_mode);
mutable.preferred_mode
);
// Reset to stdio and try again, but this time don't catch any error
mutable.preferred_mode = Some(PreferredCommunicationMode::Stdio);
self.clone().spawn(&envs, &mut mutable)?;
@ -171,7 +173,9 @@ impl PersistentPlugin {
let error_msg = match err.kind() {
std::io::ErrorKind::NotFound => match program_name {
Ok(prog_name) => {
format!("Can't find {prog_name}, please make sure that {prog_name} is in PATH.")
format!(
"Can't find {prog_name}, please make sure that {prog_name} is in PATH."
)
}
_ => {
format!("Error spawning child process: {err}")

View File

@ -2,7 +2,7 @@ use std::{cmp::Ordering, sync::Arc};
use nu_plugin_core::util::with_custom_values_in;
use nu_plugin_protocol::PluginCustomValue;
use nu_protocol::{ast::Operator, CustomValue, IntoSpanned, ShellError, Span, Spanned, Value};
use nu_protocol::{CustomValue, IntoSpanned, ShellError, Span, Spanned, Value, ast::Operator};
use serde::Serialize;
use crate::{PluginInterface, PluginSource};

View File

@ -1,12 +1,12 @@
use std::sync::Arc;
use nu_plugin_protocol::test_util::{test_plugin_custom_value, TestCustomValue};
use nu_plugin_protocol::test_util::{TestCustomValue, test_plugin_custom_value};
use nu_protocol::{
engine::Closure, record, BlockId, CustomValue, IntoSpanned, ShellError, Span, Value, VarId,
BlockId, CustomValue, IntoSpanned, ShellError, Span, Value, VarId, engine::Closure, record,
};
use crate::{
test_util::test_plugin_custom_value_with_source, PluginCustomValueWithSource, PluginSource,
PluginCustomValueWithSource, PluginSource, test_util::test_plugin_custom_value_with_source,
};
use super::WithSource;

View File

@ -1,4 +1,4 @@
use std::sync::{atomic::AtomicU32, Arc, Mutex, MutexGuard};
use std::sync::{Arc, Mutex, MutexGuard, atomic::AtomicU32};
use nu_protocol::{ShellError, Span};
use nu_system::ForegroundGuard;

View File

@ -1,7 +1,7 @@
use std::sync::Arc;
use nu_plugin_core::interface_test_util::TestCase;
use nu_plugin_protocol::{test_util::test_plugin_custom_value, PluginInput, PluginOutput};
use nu_plugin_protocol::{PluginInput, PluginOutput, test_util::test_plugin_custom_value};
use crate::{PluginCustomValueWithSource, PluginInterfaceManager, PluginSource};