Trait Handler

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

Trait that an argument handler must implement.

Required Methods§

Source

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

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§

Source§

impl<'a> Debug for dyn Handler + 'a

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Box<dyn Handler + 'a>

Source§

fn eq(&self, other: &Box<dyn Handler + 'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementors§