aboutsummaryrefslogtreecommitdiff
path: root/mingling
diff options
context:
space:
mode:
Diffstat (limited to 'mingling')
-rw-r--r--mingling/src/gen_program.rs40
1 files changed, 37 insertions, 3 deletions
diff --git a/mingling/src/gen_program.rs b/mingling/src/gen_program.rs
index 144e081..18d9117 100644
--- a/mingling/src/gen_program.rs
+++ b/mingling/src/gen_program.rs
@@ -4,11 +4,21 @@ use mingling_core::ChainProcess;
use mingling_core::Dispatcher;
use mingling_core::Grouped;
use mingling_core::Node;
+use mingling_core::Program;
use mingling_core::ProgramCollect;
/// The next processing step for the current chain.
pub type Next = ChainProcess<ThisProgram>;
+/// The generic program entry point.
+///
+/// This type is created by the `pack!` macro as a variant of the
+/// program's output type set (`ThisProgram`).
+pub struct Entry {
+ /// The arguments provided by the user
+ pub(crate) inner: Vec<String>,
+}
+
/// An enum used to record the set of program type IDs.
///
/// It contains the IDs of all types for this program, registered by the `register_type!` macro.
@@ -33,7 +43,7 @@ pub enum ThisProgram {
/// program's output type set (`ThisProgram`).
pub struct ErrorRendererNotFound {
/// The name of the renderer that was not found
- inner: String,
+ pub(crate) inner: String,
}
/// A struct representing a "dispatcher not found" error.
@@ -42,7 +52,7 @@ pub struct ErrorRendererNotFound {
/// program's output type set (`ThisProgram`).
pub struct ErrorDispatcherNotFound {
/// The arguments provided by the user
- inner: Vec<String>,
+ pub(crate) inner: Vec<String>,
}
/// A struct representing an empty result.
@@ -64,7 +74,7 @@ pub struct CMDCompletion;
#[cfg(feature = "comp")]
pub struct CompletionContext {
/// The arguments provided by the user
- inner: Vec<String>,
+ pub(crate) inner: Vec<String>,
}
/// Represents a completion suggestion result.
@@ -103,6 +113,18 @@ impl Dispatcher<ThisProgram> for CMDCompletion {
// However, these are marked `unsafe` because the `Grouped` trait requires the
// implementor to guarantee that the type is the only one associated with the
// given enum variant — a guarantee that should be carefully verified in production code.
+unsafe impl Grouped<ThisProgram> for Entry {
+ fn member_id() -> ThisProgram {
+ ThisProgram::Entry
+ }
+}
+
+// SAFETY: These implementations are provided for demonstration purposes only.
+// The `member_id()` implementations map each type to its corresponding variant
+// in the `ThisProgram` enum, and the IDs correctly correspond to the actual types.
+// However, these are marked `unsafe` because the `Grouped` trait requires the
+// implementor to guarantee that the type is the only one associated with the
+// given enum variant — a guarantee that should be carefully verified in production code.
unsafe impl Grouped<ThisProgram> for ErrorRendererNotFound {
fn member_id() -> ThisProgram {
ThisProgram::ErrorRendererNotFound
@@ -229,3 +251,15 @@ impl ProgramCollect for ThisProgram {
todo!()
}
}
+
+impl ThisProgram {
+ /// Create a program through this ProgramCollect.
+ pub fn new() -> Program<ThisProgram> {
+ todo!()
+ }
+
+ /// Get the global singleton of the current program.
+ pub fn this() -> &'static Program<ThisProgram> {
+ todo!()
+ }
+}