aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program/exec
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-10 15:49:31 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-10 15:49:31 +0800
commita9d5943939261e27e58bcf5cacbb618a0f63e999 (patch)
treed1cacc2af939e993f2d7d2794500e6456659e6a9 /mingling_core/src/program/exec
parent782d2458dc4ad4336e1407e1f107e43e39b0b991 (diff)
refactor(core): improve code style and public API clarity
Replace bool-based settings with enums, refine visibility and signatures, and standardize `Self` usage across the crate. - Introduce `ErrorOutput`, `RenderOutput`, `PanicSilence`, `Verbosity`, `ColorOutput`, and `ProgressOutput` enums for clearer configuration semantics - Make `GlobalResources`, `ProgramCell`, and `split_input`/`split_input_string` public - Change hook info parameters to accept references and `split_input_string` to take `&str` - Apply `Self` shorthand throughout implementations and add `#[must_use]` attributes where appropriate - Enable strict clippy lints with targeted allowances
Diffstat (limited to 'mingling_core/src/program/exec')
-rw-r--r--mingling_core/src/program/exec/error.rs48
1 files changed, 19 insertions, 29 deletions
diff --git a/mingling_core/src/program/exec/error.rs b/mingling_core/src/program/exec/error.rs
index 944e89a..c8cb15a 100644
--- a/mingling_core/src/program/exec/error.rs
+++ b/mingling_core/src/program/exec/error.rs
@@ -24,12 +24,12 @@ pub enum ProgramExecuteError {
impl fmt::Display for ProgramExecuteError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- ProgramExecuteError::DispatcherNotFound => write!(f, "No Dispatcher Found"),
- ProgramExecuteError::RendererNotFound(s) => {
+ Self::DispatcherNotFound => write!(f, "No Dispatcher Found"),
+ Self::RendererNotFound(s) => {
write!(f, "No Renderer (`{s}`) Found")
}
- ProgramExecuteError::Panic(p) => write!(f, "Panic: {p:?}"),
- ProgramExecuteError::Other(s) => write!(f, "Other error: {s}"),
+ Self::Panic(p) => write!(f, "Panic: {p:?}"),
+ Self::Other(s) => write!(f, "Other error: {s}"),
}
}
}
@@ -38,7 +38,7 @@ impl std::error::Error for ProgramExecuteError {}
impl From<ProgramPanic> for ProgramExecuteError {
fn from(value: ProgramPanic) -> Self {
- ProgramExecuteError::Panic(value)
+ Self::Panic(value)
}
}
@@ -70,17 +70,11 @@ pub enum ProgramInternalExecuteError {
impl fmt::Display for ProgramInternalExecuteError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- ProgramInternalExecuteError::DispatcherNotFound => {
- write!(f, "No Dispatcher Found")
- }
- ProgramInternalExecuteError::RendererNotFound(s) => {
- write!(f, "No Renderer (`{s}`) Found")
- }
- ProgramInternalExecuteError::Other(s) => write!(f, "Other error: {s}"),
- ProgramInternalExecuteError::IO(e) => write!(f, "IO error: {e}"),
- ProgramInternalExecuteError::REPLPanic(panic) => {
- write!(f, "A single REPL execution failed: {panic}")
- }
+ Self::DispatcherNotFound => write!(f, "No Dispatcher Found"),
+ Self::RendererNotFound(s) => write!(f, "No Renderer (`{s}`) Found"),
+ Self::Other(s) => write!(f, "Other error: {s}"),
+ Self::IO(e) => write!(f, "IO error: {e}"),
+ Self::REPLPanic(panic) => write!(f, "A single REPL execution failed: {panic}"),
}
}
}
@@ -88,7 +82,7 @@ impl fmt::Display for ProgramInternalExecuteError {
impl std::error::Error for ProgramInternalExecuteError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
- ProgramInternalExecuteError::IO(e) => Some(e),
+ Self::IO(e) => Some(e),
_ => None,
}
}
@@ -96,23 +90,19 @@ impl std::error::Error for ProgramInternalExecuteError {
impl From<std::io::Error> for ProgramInternalExecuteError {
fn from(e: std::io::Error) -> Self {
- ProgramInternalExecuteError::IO(e)
+ Self::IO(e)
}
}
impl From<ProgramInternalExecuteError> for ProgramExecuteError {
fn from(value: ProgramInternalExecuteError) -> Self {
match value {
- ProgramInternalExecuteError::DispatcherNotFound => {
- ProgramExecuteError::DispatcherNotFound
- }
- ProgramInternalExecuteError::RendererNotFound(s) => {
- ProgramExecuteError::RendererNotFound(s)
- }
- ProgramInternalExecuteError::Other(s) => ProgramExecuteError::Other(s),
- ProgramInternalExecuteError::IO(e) => ProgramExecuteError::Other(format!("{e}")),
+ ProgramInternalExecuteError::DispatcherNotFound => Self::DispatcherNotFound,
+ ProgramInternalExecuteError::RendererNotFound(s) => Self::RendererNotFound(s),
+ ProgramInternalExecuteError::Other(s) => Self::Other(s),
+ ProgramInternalExecuteError::IO(e) => Self::Other(format!("{e}")),
ProgramInternalExecuteError::REPLPanic(p) => {
- ProgramExecuteError::Other(format!("A single REPL execution failed: {p}"))
+ Self::Other(format!("A single REPL execution failed: {p}"))
}
}
}
@@ -121,8 +111,8 @@ impl From<ProgramInternalExecuteError> for ProgramExecuteError {
impl From<ChainProcessError> for ProgramInternalExecuteError {
fn from(value: ChainProcessError) -> Self {
match value {
- ChainProcessError::Other(s) => ProgramInternalExecuteError::Other(s),
- ChainProcessError::IO(error) => ProgramInternalExecuteError::IO(error),
+ ChainProcessError::Other(s) => Self::Other(s),
+ ChainProcessError::IO(error) => Self::IO(error),
}
}
}