[][src]Enum medusa::Variant

pub enum Variant {
    Plain(fn(_: &Handler)),
    WithArg(fn(_: &Handler, _: String)),
}

Enum that define the variants of the CLI option handlers.

There are 2 types of this variant: Plain and WithArg.

Plain means that your handler doesn't need arguments to run. For example, a handler to show help message or to output current version.

WithArg means that your handler is a function that need arguments to run. For example, a handler to use certain user to run the command.

Note that every functions that will be registered as action handler must pass a variable with type &Handler as its first parameter. This is required to make every action handler becomes stateful (means that it can parse and use all of the arguments passed to the CLI program).

Example

use medusa::Handler;

// without arguments (using `Plain` variant)
// the usage would be:
// Variant::Plain(hello);
fn hello(handler: &Handler) {
  println!("Hello, world!");
}

// with arguments (using `WithArg` variant)
// the usage would be:
// Variant::WithArg(echo);
fn echo(handler: &Handler, payload: String) {
  println!("Got payload : {}", payload);
}

Variants

Plain(fn(_: &Handler))
WithArg(fn(_: &Handler, _: String))

Trait Implementations

impl Clone for Variant[src]

Auto Trait Implementations

impl RefUnwindSafe for Variant

impl Send for Variant

impl Sync for Variant

impl Unpin for Variant

impl UnwindSafe for Variant

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.