#[non_exhaustive]pub struct CommandResult {
pub data: Value,
pub metadata: CommandResultMetadata,
}Expand description
Data returned by a command handler.
Command handlers should return renderable data and keep output metadata on
CommandSpec. The metadata field is reserved for future command-result
extensions that are not known when the command is registered.
Construct with CommandResult::new, then chain with_* methods —
never as a struct literal. #[non_exhaustive] enforces this so the engine
can add fields without a breaking release.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.data: ValueJSON data rendered by the configured output formatter.
metadata: CommandResultMetadataOptional command-result extension metadata.
Implementations§
Source§impl CommandResult
impl CommandResult
Sourcepub fn with_next_actions(self, actions: Vec<NextAction>) -> Self
pub fn with_next_actions(self, actions: Vec<NextAction>) -> Self
Attaches suggested follow-up actions to this result.
Sourcepub fn with_dry_run(self) -> Self
pub fn with_dry_run(self) -> Self
Marks this result as a dry-run preview outcome.
Call only when the handler actually skipped its mutating step because
CommandContext::dry_run was true. This requires the command to
have opted in via CommandSpec::handles_dry_run — otherwise
middleware never invokes the handler under --dry-run in the first
place. Middleware tags the audit/activity outcome as dry-run instead
of ok and marks the rendered envelope accordingly.
Trait Implementations§
Source§impl Clone for CommandResult
impl Clone for CommandResult
Source§fn clone(&self) -> CommandResult
fn clone(&self) -> CommandResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more