pub struct CommandsAggregatorFormer<__FormerContext = CommandsAggregator, __FormerEnd = ReturnContainer>
where __FormerEnd: ToSuperFormer<CommandsAggregator, __FormerContext>,
{ /* private fields */ }
Expand description

Object to form CommandsAggregator. If field’s values is not set then default value of the field is set.

For specifying custom default value use attribute default. For example:


use former::Former;
#[ derive( Former ) ]
pub struct Struct1
{
  #[default( 31 ) ]
  field1 : i32,
}

Implementations§

source§

impl<__FormerContext, __FormerEnd> CommandsAggregatorFormer<__FormerContext, __FormerEnd>
where __FormerEnd: ToSuperFormer<CommandsAggregator, __FormerContext>,

source

pub fn form(self) -> CommandsAggregator

Finish setting options and return formed entity.

perform has no effect on method form, but change behavior and returned type of method perform.

source

pub fn perform(self) -> CommandsAggregator

Finish setting options and call perform on formed entity.

If perform defined then associated method is called and its result returned instead of entity. For example perform() of structure with : #[ perform( fn after1() -> &str > ) returns &str.

source

pub fn new() -> CommandsAggregatorFormer<CommandsAggregator, ReturnContainer>

Construct new instance of former with default parameters.

source

pub fn begin(context: Option<__FormerContext>, on_end: __FormerEnd) -> Self

Begin the process of forming. Expects context of forming to return it after forming.

source

pub fn end(self) -> __FormerContext

End the process of forming returning original context of forming.

source

pub fn dictionary<Src>(self, src: Src) -> Self
where Src: Into<Dictionary>,

Setter for the ‘dictionary’ field.

source

pub fn parser<Src>(self, src: Src) -> Self
where Src: Into<Parser>,

Setter for the ‘parser’ field.

source

pub fn help_generator<Src>(self, src: Src) -> Self
where Src: Into<HelpGeneratorFn>,

Setter for the ‘help_generator’ field.

source

pub fn help_variants<Src>(self, src: Src) -> Self
where Src: Into<HashSet<HelpVariants>>,

Setter for the ‘help_variants’ field.

source

pub fn verifier<Src>(self, src: Src) -> Self
where Src: Into<Verifier>,

Setter for the ‘verifier’ field.

source

pub fn callback_fn<Src>(self, src: Src) -> Self
where Src: Into<CommandsAggregatorCallback>,

Setter for the ‘callback_fn’ field.

source§

impl<Context, End> CommandsAggregatorFormer<Context, End>
where End: ToSuperFormer<CommandsAggregator, Context>,

source

pub fn command<IntoName>( self, name: IntoName ) -> CommandFormer<Self, impl ToSuperFormer<Command, Self>>
where IntoName: Into<String>,

Creates a command in the command chain.

§Arguments
  • name - The name of the command.
source§

impl CommandsAggregatorFormer

source

pub fn help<HelpFunction>(self, func: HelpFunction) -> Self
where HelpFunction: Fn(&Dictionary, Option<&Command>) -> String + 'static,

Setter for help content generator

use wca::CommandsAggregator;

let ca = CommandsAggregator::former()
// ...
.help( | grammar, command | format!( "Replaced help content" ) )
.perform();

ca.perform( ".help" )?;
source

pub fn callback<Callback>(self, callback: Callback) -> Self
where Callback: Fn(&str, &Program<VerifiedCommand>) + 'static,

Set callback function that will be executed after validation state

use wca::CommandsAggregator;

let ca = CommandsAggregator::former()
// ...
.callback( | _input, _program | println!( "Program is valid" ) )
.perform();

// prints the "Program is valid" and after executes the program
ca.perform( ".help" )?;

Auto Trait Implementations§

§

impl<__FormerContext, __FormerEnd> Freeze for CommandsAggregatorFormer<__FormerContext, __FormerEnd>
where __FormerContext: Freeze, __FormerEnd: Freeze,

§

impl<__FormerContext = CommandsAggregator, __FormerEnd = ReturnContainer> !RefUnwindSafe for CommandsAggregatorFormer<__FormerContext, __FormerEnd>

§

impl<__FormerContext = CommandsAggregator, __FormerEnd = ReturnContainer> !Send for CommandsAggregatorFormer<__FormerContext, __FormerEnd>

§

impl<__FormerContext = CommandsAggregator, __FormerEnd = ReturnContainer> !Sync for CommandsAggregatorFormer<__FormerContext, __FormerEnd>

§

impl<__FormerContext, __FormerEnd> Unpin for CommandsAggregatorFormer<__FormerContext, __FormerEnd>
where __FormerContext: Unpin, __FormerEnd: Unpin,

§

impl<__FormerContext = CommandsAggregator, __FormerEnd = ReturnContainer> !UnwindSafe for CommandsAggregatorFormer<__FormerContext, __FormerEnd>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<S> SetWithType for S

source§

fn set_with_type<T, IntoT>(&mut self, component: IntoT)
where IntoT: Into<T>, S: SetComponent<T, IntoT>,

Function to set value of a component by its type.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Any for T
where T: Any,