Trait ap::Handler[][src]

pub trait Handler {
    fn handle(&mut self, arg: Arg) -> Result<()>;
}
Expand description

Trait that an argument handler must implement.

Required methods

fn handle(&mut self, arg: Arg) -> Result<()>[src]

Function that will handle all registered options.

Since the handler is provided with a mutable reference to itself, it can store and modify its state when called.

Parameters

arg - The Arg provides details of the argument found on the command-line.

Return value

  • If the handler logic succeeds, return Ok(()).
  • If the handler needs to fail, it should return one of the Error values. If the main errors are not appropriate, make the handler return Error::HandlerError.

Notes

If a handler call fails, the command-line parsing will stop and the error will be returned to the caller of the parsing function.

Trait Implementations

impl<'a> Debug for dyn Handler + 'a[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Implementors