From f1ed18e668a830646fe507ee33c4b010a1690342 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 1 Apr 2026 20:14:56 +0800 Subject: Add documentation for mingling_core --- mingling_core/src/program.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mingling_core/src/program.rs') diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs index ffba17e..5d81234 100644 --- a/mingling_core/src/program.rs +++ b/mingling_core/src/program.rs @@ -4,7 +4,9 @@ use crate::{ }; use std::{env, fmt::Display, pin::Pin}; +#[doc(hidden)] pub mod exec; +#[doc(hidden)] pub mod setup; mod config; @@ -14,6 +16,7 @@ mod flag; pub use flag::*; use tokio::io::AsyncWriteExt; +/// Program, used to define the behavior of the entire command-line program #[derive(Default)] pub struct Program where @@ -86,15 +89,31 @@ where } } +/// Collected program context +/// +/// Note: It is recommended to use the `gen_program!()` macro from [mingling_macros](https://crates.io/crates/mingling_macros) to automatically create this type pub trait ProgramCollect { + /// Enum type representing internal IDs for the program type Enum: Display; + + /// Build an [AnyOutput](./struct.AnyOutput.html) to indicate that a renderer was not found fn build_renderer_not_found(member_id: Self::Enum) -> AnyOutput; + + /// Build an [AnyOutput](./struct.AnyOutput.html) to indicate that a dispatcher was not found fn build_dispatcher_not_found(args: Vec) -> AnyOutput; + + /// Render the input [AnyOutput](./struct.AnyOutput.html) fn render(any: AnyOutput, r: &mut RenderResult); + + /// Find a matching chain to continue execution based on the input [AnyOutput](./struct.AnyOutput.html), returning a new [AnyOutput](./struct.AnyOutput.html) fn do_chain( any: AnyOutput, ) -> Pin> + Send>>; + + /// Whether the program has a renderer that can handle the current [AnyOutput](./struct.AnyOutput.html) fn has_renderer(any: &AnyOutput) -> bool; + + /// Whether the program has a chain that can handle the current [AnyOutput](./struct.AnyOutput.html) fn has_chain(any: &AnyOutput) -> bool; } -- cgit