Struct wca::CommandsAggregatorFormer
source · 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>,
impl<__FormerContext, __FormerEnd> CommandsAggregatorFormer<__FormerContext, __FormerEnd>where
__FormerEnd: ToSuperFormer<CommandsAggregator, __FormerContext>,
sourcepub fn form(self) -> CommandsAggregator
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.
sourcepub fn perform(self) -> CommandsAggregator
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.
sourcepub fn new() -> CommandsAggregatorFormer<CommandsAggregator, ReturnContainer>
pub fn new() -> CommandsAggregatorFormer<CommandsAggregator, ReturnContainer>
Construct new instance of former with default parameters.
sourcepub fn begin(context: Option<__FormerContext>, on_end: __FormerEnd) -> Self
pub fn begin(context: Option<__FormerContext>, on_end: __FormerEnd) -> Self
Begin the process of forming. Expects context of forming to return it after forming.
sourcepub fn end(self) -> __FormerContext
pub fn end(self) -> __FormerContext
End the process of forming returning original context of forming.
sourcepub fn dictionary<Src>(self, src: Src) -> Selfwhere
Src: Into<Dictionary>,
pub fn dictionary<Src>(self, src: Src) -> Selfwhere
Src: Into<Dictionary>,
Setter for the ‘dictionary’ field.
sourcepub fn help_generator<Src>(self, src: Src) -> Selfwhere
Src: Into<HelpGeneratorFn>,
pub fn help_generator<Src>(self, src: Src) -> Selfwhere
Src: Into<HelpGeneratorFn>,
Setter for the ‘help_generator’ field.
sourcepub fn help_variants<Src>(self, src: Src) -> Self
pub fn help_variants<Src>(self, src: Src) -> Self
Setter for the ‘help_variants’ field.
sourcepub fn callback_fn<Src>(self, src: Src) -> Selfwhere
Src: Into<CommandsAggregatorCallback>,
pub fn callback_fn<Src>(self, src: Src) -> Selfwhere
Src: Into<CommandsAggregatorCallback>,
Setter for the ‘callback_fn’ field.
source§impl<Context, End> CommandsAggregatorFormer<Context, End>where
End: ToSuperFormer<CommandsAggregator, Context>,
impl<Context, End> CommandsAggregatorFormer<Context, End>where
End: ToSuperFormer<CommandsAggregator, Context>,
sourcepub fn command<IntoName>(
self,
name: IntoName
) -> CommandFormer<Self, impl ToSuperFormer<Command, Self>>
pub fn command<IntoName>( self, name: IntoName ) -> CommandFormer<Self, impl ToSuperFormer<Command, Self>>
source§impl CommandsAggregatorFormer
impl CommandsAggregatorFormer
sourcepub fn help<HelpFunction>(self, func: HelpFunction) -> Self
pub fn help<HelpFunction>(self, func: HelpFunction) -> Self
Setter for help content generator
use wca::CommandsAggregator;
let ca = CommandsAggregator::former()
// ...
.help( | grammar, command | format!( "Replaced help content" ) )
.perform();
ca.perform( ".help" )?;sourcepub fn callback<Callback>(self, callback: Callback) -> Self
pub fn callback<Callback>(self, callback: Callback) -> Self
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" )?;