aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-05-29 17:13:36 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-29 17:13:36 +0800
commit6edaa76d67ab1ff211c7cc9cd179ffbefe93a04f (patch)
tree02d5b5f68b3d443baccbfc0ed3fc7fa16a3dd9a4 /mingling_macros
parent05826d67f1f9166a6620475ffdeaa488917befd8 (diff)
Rename error types with consistent naming convention
Diffstat (limited to 'mingling_macros')
-rw-r--r--mingling_macros/src/chain.rs8
-rw-r--r--mingling_macros/src/lib.rs50
2 files changed, 29 insertions, 29 deletions
diff --git a/mingling_macros/src/chain.rs b/mingling_macros/src/chain.rs
index 559468c..ac05480 100644
--- a/mingling_macros/src/chain.rs
+++ b/mingling_macros/src/chain.rs
@@ -95,7 +95,7 @@ fn generate_proc_fn(
let body_stmts: &[syn::Stmt] = if is_unit_return && has_resources {
let mut stmts = fn_body_stmts.to_vec();
stmts.push(syn::Stmt::Expr(
- syn::parse_quote! { crate::EmptyResult::new(()).to_chain() },
+ syn::parse_quote! { crate::ResultEmpty::new(()).to_chain() },
None,
));
// Box::leak to get a &'static [syn::Stmt]
@@ -106,7 +106,7 @@ fn generate_proc_fn(
let wrapped_body = wrap_body_with_mut_resources(body_stmts, &mut_resources, program_type);
- // When the function returns `()`, wrap the result with EmptyResult
+ // When the function returns `()`, wrap the result with ResultEmpty
let call_or_wrapped = if is_unit_return {
if has_resources {
quote! {
@@ -121,7 +121,7 @@ fn generate_proc_fn(
};
quote! {
#call
- crate::EmptyResult::new(()).to_chain()
+ crate::ResultEmpty::new(()).to_chain()
}
}
} else if has_resources {
@@ -179,7 +179,7 @@ fn generate_original_fn(
quote! {
{
#fn_body
- crate::EmptyResult::new(()).to_chain()
+ crate::ResultEmpty::new(()).to_chain()
}
}
} else {
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index f0ba25b..8cae29f 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -244,7 +244,7 @@ pub fn route(input: TokenStream) -> TokenStream {
/// Creates an empty result value wrapped in `ChainProcess` for early return
/// from a chain function.
///
-/// This macro is a shorthand for constructing an `EmptyResult` and converting
+/// This macro is a shorthand for constructing an `ResultEmpty` and converting
/// it into a `ChainProcess`, which signals to the pipeline that there is
/// no meaningful output to continue processing.
///
@@ -273,16 +273,16 @@ pub fn route(input: TokenStream) -> TokenStream {
///
/// The macro expands to:
/// ```rust,ignore
-/// crate::EmptyResult::new(()).to_chain()
+/// crate::ResultEmpty::new(()).to_chain()
/// ```
///
-/// This works because `EmptyResult` is automatically generated by `gen_program!`
+/// This works because `ResultEmpty` is automatically generated by `gen_program!`
/// and implements the necessary trait conversions into `ChainProcess`.
#[cfg(feature = "extra_macros")]
#[proc_macro]
pub fn empty_result(_input: TokenStream) -> TokenStream {
let expanded = quote! {
- crate::EmptyResult::new(()).to_chain()
+ crate::ResultEmpty::new(()).to_chain()
};
TokenStream::from(expanded)
}
@@ -631,17 +631,17 @@ pub fn chain(attr: TokenStream, item: TokenStream) -> TokenStream {
///
/// The macros `gen_program!` automatically generates two fallback types that
/// you can provide renderers for:
-/// - `RendererNotFound` — triggered when no matching renderer is found
-/// - `DispatcherNotFound` — triggered when no matching dispatcher is found
+/// - `ErrorRendererNotFound` — triggered when no matching renderer is found
+/// - `ErrorDispatcherNotFound` — triggered when no matching dispatcher is found
///
/// ```rust,ignore
/// #[renderer]
-/// fn fallback_dispatcher_not_found(prev: DispatcherNotFound) {
+/// fn fallback_dispatcher_not_found(prev: ErrorDispatcherNotFound) {
/// r_println!("Unknown command: {}", prev.join(", "));
/// }
///
/// #[renderer]
-/// fn fallback_renderer_not_found(prev: RendererNotFound) {
+/// fn fallback_renderer_not_found(prev: ErrorRendererNotFound) {
/// r_println!("No renderer for `{}`", *prev);
/// }
/// ```
@@ -1046,7 +1046,7 @@ pub fn derive_groupped_serialize(input: TokenStream) -> TokenStream {
/// 1. **`pub type Next = ChainProcess<ProgramName>`** — A convenience type alias
/// for use in chain function return types.
/// 2. **`program_comp_gen!(...)`** (with `comp` feature) — Generates completion infrastructure.
-/// 3. **`program_fallback_gen!(...)`** — Generates `RendererNotFound` and `DispatcherNotFound` types.
+/// 3. **`program_fallback_gen!(...)`** — Generates `ErrorRendererNotFound` and `ErrorDispatcherNotFound` types.
/// 4. **`program_final_gen!(...)`** — Generates the program enum with:
/// - An enum with all packed types as variants
/// - `Display` implementation for the enum
@@ -1258,11 +1258,11 @@ pub fn register_renderer(input: TokenStream) -> TokenStream {
/// This macro generates the fallback wrapper types that are essential
/// for error handling in the Mingling pipeline:
///
-/// - **`RendererNotFound`** — Wraps a `String` (the name of the missing renderer).
+/// - **`ErrorRendererNotFound`** — Wraps a `String` (the name of the missing renderer).
/// Used when no matching renderer is found for a given output type.
-/// - **`DispatcherNotFound`** — Wraps `Vec<String>` (the unrecognized command args).
+/// - **`ErrorDispatcherNotFound`** — Wraps `Vec<String>` (the unrecognized command args).
/// Used when no matching dispatcher is found for user input.
-/// - **`EmptyResult`** — Wraps `()` (the unit type).
+/// - **`ResultEmpty`** — Wraps `()` (the unit type).
/// Used when the chain returns an empty result.
///
/// Users can (and should) write `#[renderer]` functions for these types
@@ -1282,18 +1282,18 @@ pub fn register_renderer(input: TokenStream) -> TokenStream {
/// # Generated code equivalent
///
/// ```rust,ignore
-/// pack!(ProgramName, RendererNotFound = String);
-/// pack!(ProgramName, DispatcherNotFound = Vec<String>);
-/// pack!(ProgramName, EmptyResult = ());
+/// pack!(ProgramName, ErrorRendererNotFound = String);
+/// pack!(ProgramName, ErrorDispatcherNotFound = Vec<String>);
+/// pack!(ProgramName, ResultEmpty = ());
/// ```
#[proc_macro]
pub fn program_fallback_gen(input: TokenStream) -> TokenStream {
let name = read_name(&input);
let expanded = quote! {
- ::mingling::macros::pack!(#name, RendererNotFound = String);
- ::mingling::macros::pack!(#name, DispatcherNotFound = Vec<String>);
- ::mingling::macros::pack!(#name, EmptyResult = ());
+ ::mingling::macros::pack!(#name, ErrorRendererNotFound = String);
+ ::mingling::macros::pack!(#name, ErrorDispatcherNotFound = Vec<String>);
+ ::mingling::macros::pack!(#name, ResultEmpty = ());
};
TokenStream::from(expanded)
}
@@ -1334,7 +1334,7 @@ pub fn program_fallback_gen(input: TokenStream) -> TokenStream {
///
/// impl ProgramCollect for MyProgram {
/// type Enum = MyProgram;
-/// type EmptyResult = EmptyResult;
+/// type ResultEmpty = ResultEmpty;
/// fn render(any, r) { /* dispatches to all registered renderers */ }
/// fn do_chain(any) -> ChainProcess { /* dispatches to all registered chain steps */ }
/// fn render_help(any, r) { /* dispatches to all registered help handlers */ }
@@ -1506,17 +1506,17 @@ pub fn program_final_gen(input: TokenStream) -> TokenStream {
impl ::mingling::ProgramCollect for #name {
type Enum = #name;
- type DispatcherNotFound = DispatcherNotFound;
- type RendererNotFound = RendererNotFound;
- type EmptyResult = EmptyResult;
+ type ErrorDispatcherNotFound = ErrorDispatcherNotFound;
+ type ErrorRendererNotFound = ErrorRendererNotFound;
+ type ResultEmpty = ResultEmpty;
fn build_renderer_not_found(member_id: Self::Enum) -> ::mingling::AnyOutput<Self::Enum> {
- ::mingling::AnyOutput::new(RendererNotFound::new(member_id.to_string()))
+ ::mingling::AnyOutput::new(ErrorRendererNotFound::new(member_id.to_string()))
}
fn build_dispatcher_not_found(args: Vec<String>) -> ::mingling::AnyOutput<Self::Enum> {
- ::mingling::AnyOutput::new(DispatcherNotFound::new(args))
+ ::mingling::AnyOutput::new(ErrorDispatcherNotFound::new(args))
}
fn build_empty_result() -> ::mingling::AnyOutput<Self::Enum> {
- ::mingling::AnyOutput::new(EmptyResult::new(()))
+ ::mingling::AnyOutput::new(ResultEmpty::new(()))
}
::mingling::__dispatch_program_renderers!(
#(#renderer_tokens)*