summaryrefslogtreecommitdiff
path: root/mingling_core/src/program.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-01 20:14:56 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-01 20:16:17 +0800
commitf1ed18e668a830646fe507ee33c4b010a1690342 (patch)
tree6d13b5ca65ec4df6b8df1c03df3c96301d435bbf /mingling_core/src/program.rs
parent227e710fe716c8901ee02e670a57fb70eb3f222b (diff)
Add documentation for mingling_core
Diffstat (limited to 'mingling_core/src/program.rs')
-rw-r--r--mingling_core/src/program.rs19
1 files changed, 19 insertions, 0 deletions
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<C, G>
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<Self::Enum>;
+
+ /// Build an [AnyOutput](./struct.AnyOutput.html) to indicate that a dispatcher was not found
fn build_dispatcher_not_found(args: Vec<String>) -> AnyOutput<Self::Enum>;
+
+ /// Render the input [AnyOutput](./struct.AnyOutput.html)
fn render(any: AnyOutput<Self::Enum>, 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<Self::Enum>,
) -> Pin<Box<dyn Future<Output = ChainProcess<Self::Enum>> + Send>>;
+
+ /// Whether the program has a renderer that can handle the current [AnyOutput](./struct.AnyOutput.html)
fn has_renderer(any: &AnyOutput<Self::Enum>) -> bool;
+
+ /// Whether the program has a chain that can handle the current [AnyOutput](./struct.AnyOutput.html)
fn has_chain(any: &AnyOutput<Self::Enum>) -> bool;
}