Remove nu-glob's dependency on nu-protocol (#15349)

# Description

This PR solves a circular dependency issue (`nu-test-support` needs
`nu-glob` which needs `nu-protocol` which needs `nu-test-support`). This
was done by making the glob functions that any type that implements
`Interruptible` to remove the dependency on `Signals`.

# After Submitting

Make `Paths.next()` a O(1) operation so that cancellation/interrupt
handling can be moved to the caller (e.g., by wrapping the `Paths`
iterator in a cancellation iterator).
This commit is contained in:
Ian Manske
2025-03-20 09:32:41 -07:00
committed by GitHub
parent b241e9edd5
commit dfba62da00
8 changed files with 81 additions and 59 deletions

View File

@ -1,11 +1,11 @@
use crate::{ShellError, Span};
use nu_glob::Interruptible;
use serde::{Deserialize, Serialize};
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
use serde::{Deserialize, Serialize};
/// Used to check for signals to suspend or terminate the execution of Nushell code.
///
/// For now, this struct only supports interruption (ctrl+c or SIGINT).
@ -84,6 +84,13 @@ impl Signals {
}
}
impl Interruptible for Signals {
#[inline]
fn interrupted(&self) -> bool {
self.interrupted()
}
}
/// The types of things that can be signaled. It's anticipated this will change as we learn more
/// about how we'd like signals to be handled.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]