aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src')
-rw-r--r--mingling_core/src/any.rs15
-rw-r--r--mingling_core/src/lib.rs6
-rw-r--r--mingling_core/src/program.rs20
-rw-r--r--mingling_core/src/program/collection.rs8
-rw-r--r--mingling_core/src/renderer/render_result.rs5
-rw-r--r--mingling_core/src/renderer/structural/error.rs1
6 files changed, 55 insertions, 0 deletions
diff --git a/mingling_core/src/any.rs b/mingling_core/src/any.rs
index e6b7406..ec29a1b 100644
--- a/mingling_core/src/any.rs
+++ b/mingling_core/src/any.rs
@@ -17,7 +17,18 @@ pub mod group;
#[derive(Debug)]
pub struct AnyOutput<G> {
pub(crate) inner: Box<dyn std::any::Any + Send + 'static>,
+
+ /// The [`TypeId`] of the concrete type stored in `inner`.
+ ///
+ /// This is set during construction and used for type-checking
+ /// in downcast, restore, and is methods.
pub type_id: std::any::TypeId,
+
+ /// The variant identifier returned by [`Grouped::member_id`] for the
+ /// concrete type stored in `inner`.
+ ///
+ /// This is used by the scheduler to dispatch on the correct enum
+ /// variant when routing the output.
pub member_id: G,
}
@@ -106,7 +117,9 @@ impl<G> std::ops::DerefMut for AnyOutput<G> {
/// - Returns `Ok((`[`AnyOutput`](./struct.AnyOutput.html)`, `[`NextProcess::Renderer`](./enum.NextProcess.html)`))` to render this type next and output to the terminal
/// - Returns `Err(`[`ChainProcessError`](./error/enum.ChainProcessError.html)`]` to terminate the program directly
pub enum ChainProcess<G> {
+ /// Indicates success, containing the output value and the next step to execute.
Ok((AnyOutput<G>, NextProcess)),
+ /// Indicates a processing failure, containing the error that occurred.
Err(ChainProcessError),
}
@@ -117,7 +130,9 @@ pub enum ChainProcess<G> {
#[derive(Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum NextProcess {
+ /// Continue execution to the next chain
Chain,
+ /// Send output to renderer and end execution
Renderer,
}
diff --git a/mingling_core/src/lib.rs b/mingling_core/src/lib.rs
index 4996b19..2cb24b9 100644
--- a/mingling_core/src/lib.rs
+++ b/mingling_core/src/lib.rs
@@ -8,6 +8,8 @@
//!
//! Recommended to import [mingling](https://crates.io/crates/mingling) to use its features.
+#![deny(missing_docs)]
+
mod any;
mod asset;
mod program;
@@ -77,6 +79,10 @@ pub mod comp;
#[cfg(feature = "comp")]
pub use crate::comp::*;
+/// Module for setting up a `Mingling` program.
+///
+/// This module provides the [`ProgramSetup`] type, which allows users to configure
+/// and initialize the program's execution environment.
pub mod setup {
pub use crate::program::setup::ProgramSetup;
}
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs
index 0d409b7..11e1bbf 100644
--- a/mingling_core/src/program.rs
+++ b/mingling_core/src/program.rs
@@ -53,10 +53,30 @@ where
#[cfg(not(feature = "dispatch_tree"))]
pub(crate) dispatcher: Vec<Box<dyn Dispatcher<C> + Send + Sync>>,
+ /// Program stdout settings.
+ ///
+ /// This struct controls the program's output behavior, including whether
+ /// to output errors, render results, suppress panic messages, enable
+ /// verbose/quiet/debug modes, colored output, and progress indicators.
+ ///
+ /// # Convention-only fields
+ ///
+ /// Fields marked with convention only are not enforced by the framework;
+ /// they serve as a shared convention for applications to follow consistently.
pub stdout_setting: ProgramStdoutSetting,
+
+ /// User-defined context that can be accessed throughout the program.
+ ///
+ /// This field holds a user-defined context value that can be
+ /// accessed and modified at any point during program execution. It is
+ /// useful for passing shared state or configuration across different
+ /// parts of the program.
pub user_context: ProgramUserContext,
#[cfg(feature = "structural_renderer")]
+ /// Setting for the structural renderer.
+ ///
+ /// This field is only available when the `structural_renderer` feature is enabled.
pub structural_renderer_name: StructuralRendererSetting,
pub(crate) hooks: Vec<ProgramHook<C>>,
diff --git a/mingling_core/src/program/collection.rs b/mingling_core/src/program/collection.rs
index fe78979..14705ac 100644
--- a/mingling_core/src/program/collection.rs
+++ b/mingling_core/src/program/collection.rs
@@ -21,8 +21,16 @@ pub use mock::*;
pub trait ProgramCollect {
/// Enum type representing internal IDs for the program
type Enum;
+ /// Error type when a dispatcher is not found for the given member
type ErrorDispatcherNotFound: Grouped<Self::Enum>;
+
+ /// Error type when a renderer is not found for the given member
type ErrorRendererNotFound: Grouped<Self::Enum>;
+
+ /// Result type for an empty chain result
+ ///
+ /// When the `extra_macros` feature is enabled,
+ /// you can use the `empty_result!()` macro to create this
type ResultEmpty: Grouped<Self::Enum>;
/// Use a prefix tree to quickly match arguments and dispatch to an Entry
diff --git a/mingling_core/src/renderer/render_result.rs b/mingling_core/src/renderer/render_result.rs
index 763f6fc..2c60fa4 100644
--- a/mingling_core/src/renderer/render_result.rs
+++ b/mingling_core/src/renderer/render_result.rs
@@ -8,6 +8,11 @@ use std::{
#[derive(Default, Debug, PartialEq)]
pub struct RenderResult {
render_text: String,
+
+ /// The exit code to return from the rendering process.
+ ///
+ /// A value of `0` indicates success, while non-zero values indicate
+ /// various error conditions.
pub exit_code: i32,
}
diff --git a/mingling_core/src/renderer/structural/error.rs b/mingling_core/src/renderer/structural/error.rs
index a7fbc75..63ded81 100644
--- a/mingling_core/src/renderer/structural/error.rs
+++ b/mingling_core/src/renderer/structural/error.rs
@@ -9,6 +9,7 @@ pub struct StructuralRendererSerializeError {
}
impl StructuralRendererSerializeError {
+ /// Creates a new `StructuralRendererSerializeError` with the given error message.
#[must_use]
pub fn new(error: String) -> Self {
Self { error }