pub struct Hooks { /* private fields */ }Expand description
Per-command hook configuration.
Hooks are registered per-command path and executed in order.
Implementations§
Source§impl Hooks
impl Hooks
Sourcepub fn pre_dispatch<F>(self, f: F) -> Self
pub fn pre_dispatch<F>(self, f: F) -> Self
Adds a pre-dispatch hook.
Sourcepub fn post_dispatch<F>(self, f: F) -> Selfwhere
F: Fn(&ArgMatches, &CommandContext, Value) -> Result<Value, HookError> + Send + Sync + 'static,
pub fn post_dispatch<F>(self, f: F) -> Selfwhere
F: Fn(&ArgMatches, &CommandContext, Value) -> Result<Value, HookError> + Send + Sync + 'static,
Adds a post-dispatch hook.
Sourcepub fn post_output<F>(self, f: F) -> Selfwhere
F: Fn(&ArgMatches, &CommandContext, RenderedOutput) -> Result<RenderedOutput, HookError> + Send + Sync + 'static,
pub fn post_output<F>(self, f: F) -> Selfwhere
F: Fn(&ArgMatches, &CommandContext, RenderedOutput) -> Result<RenderedOutput, HookError> + Send + Sync + 'static,
Adds a post-output hook.
Sourcepub fn run_pre_dispatch(
&self,
matches: &ArgMatches,
ctx: &CommandContext,
) -> Result<(), HookError>
pub fn run_pre_dispatch( &self, matches: &ArgMatches, ctx: &CommandContext, ) -> Result<(), HookError>
Runs all pre-dispatch hooks.
Sourcepub fn run_post_dispatch(
&self,
matches: &ArgMatches,
ctx: &CommandContext,
data: Value,
) -> Result<Value, HookError>
pub fn run_post_dispatch( &self, matches: &ArgMatches, ctx: &CommandContext, data: Value, ) -> Result<Value, HookError>
Runs all post-dispatch hooks, chaining transformations.
Sourcepub fn run_post_output(
&self,
matches: &ArgMatches,
ctx: &CommandContext,
output: RenderedOutput,
) -> Result<RenderedOutput, HookError>
pub fn run_post_output( &self, matches: &ArgMatches, ctx: &CommandContext, output: RenderedOutput, ) -> Result<RenderedOutput, HookError>
Runs all post-output hooks, chaining transformations.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hooks
impl !RefUnwindSafe for Hooks
impl Send for Hooks
impl Sync for Hooks
impl Unpin for Hooks
impl !UnwindSafe for Hooks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more