[−][src]Enum medusa::Variant
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
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,