Skip to main content

Crate standout_dispatch

Crate standout_dispatch 

Source
Expand description

Command dispatch and orchestration for clap-based CLIs.

Routes parsed ArgMatches to a Handler, running pre-dispatch, handler, post-dispatch, and post-output hooks around it, and returns typed HandlerResult data — presentation stays with the consuming framework. A handler adapter takes (&ArgMatches, &CommandContext) and returns serializable data, so application logic stays reusable outside a CLI. The third parameter of Handler::handle is the typed results channel of [results]; a batch command sets Handler::Event to NoEvents and ignores it, and a command that produces its result while it runs takes the channel as a third closure parameter through EventsFnHandler.

CommandContext carries two kinds of injected state: app_state is immutable and app-lifetime (database, config, API clients), built once and shared via Rc; extensions is mutable and per-request, set by pre-dispatch hooks for things like a resolved user session.

Re-exports§

pub use artifact::Artifact;
pub use artifact::ArtifactDestination;
pub use artifact::ArtifactReceipt;
pub use artifact::ArtifactRun;

Modules§

artifact
verify

Structs§

AppFailure
ArtifactOutput
CommandContext
Diagnostic
DiagnosticPosition
DiagnosticRange
Envelope
EventsFnHandler
The adapter behind a three-argument closure, whose third parameter is the command’s typed results channel, so Event is the closure’s event type.
ExitStatus
Extensions
ExternalFailure
FnHandler
HookError
Hooks
InvalidAppStatus
InvalidExternalStatus
Results
The handler’s channel for the values a command produces while it runs.
RunError
RunOutput
RunRecorder
Retains the run’s result values and its delivery decision.
SimpleFnHandler
StreamCapture
StreamSink
TextOutput

Enums§

Delivery
Where the run’s rendered bytes went. Pager carries the shell word list the environment named, decided without starting the pager.
DiagnosticKind
DispatchResult
EmitError
HookPhase
NoEvents
The event type of a command that emits none: uninhabited, so emit has no argument that can be constructed.
Output
OutputKind
RenderedOutput
RunErrorKind
Severity
SuccessKind
Summary
What a command that declares events returns once the events are done: they already carried the run’s results, so a payload has nowhere left to go.

Traits§

ContractSurface
EventSink
The representation’s destination for one emitted event.
Handler
HandlerOutcome
What Handler::handle may return, tied to the command’s event type: Output<T> is an outcome only for NoEvents, so a command that declares events has Summary<T> and no payload variant to return.
IntoHandlerResult
IntoSummaryResult

Functions§

emits_events
Whether a command whose Handler::Event is E produces its result while it runs: false for NoEvents and true for every other event type.
extract_command_path
get_deepest_matches
has_subcommand
insert_default_command
path_to_string
string_to_path

Type Aliases§

HandlerResult
PostDispatchFn
PostOutputFn
PreDispatchFn
SummaryResult