1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2026 Kirky.X
// SPDX-License-Identifier: MIT
//! `CliHandlerRegistration` — closure-based handler registration for CLI
//! commands.
//!
//! Pairing a `CliCommandRegistration` (metadata: name, args, version) with
//! an actual invocable handler is done via a separate inventory entry. The
//! macro emits both `inventory::submit!(CliCommandRegistration { ... })`
//! and `inventory::submit!(CliHandlerRegistration { ... })` for each
//! `#[service_api(cli = true)]` function.
//!
//! The handler signature takes a `HashMap<String, String>` (the string-typed
//! argument values parsed by clap) and returns a pinned boxed future. This
//! mirrors the design trade-off noted in `design.md` (A3): type-safety is
//! traded for inventory simplicity — argument deserialization happens inside
//! the macro-generated closure.
use crateApiError;
use HashMap;
use Future;
use Pin;
/// Type alias for the handler function pointer.
///
/// `fn(HashMap<String, String>) -> Pin<Box<dyn Future<Output = Result<(), ApiError>> + Send + 'static>>`
pub type CliHandlerFn = fn ;
/// Static registration pairing a command name with its handler closure.
///
/// Looked up at call time by `name` (matching `CliCommandRegistration::name`)
/// to dispatch the user's selected subcommand. Submitted at compile time
/// via `inventory::submit!` from the `#[service_api]` macro.
collect!;