Struct wca::CommandFormer
source · pub struct CommandFormer<__FormerContext = Command, __FormerEnd = ReturnContainer>where
__FormerEnd: ToSuperFormer<Command, __FormerContext>,{ /* private fields */ }Expand description
Object to form Command. 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> CommandFormer<__FormerContext, __FormerEnd>where
__FormerEnd: ToSuperFormer<Command, __FormerContext>,
impl<__FormerContext, __FormerEnd> CommandFormer<__FormerContext, __FormerEnd>where
__FormerEnd: ToSuperFormer<Command, __FormerContext>,
sourcepub fn form(self) -> Command
pub fn form(self) -> Command
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) -> Command
pub fn perform(self) -> Command
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() -> CommandFormer<Command, ReturnContainer>
pub fn new() -> CommandFormer<Command, 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 properties<Src>(self, src: Src) -> Self
pub fn properties<Src>(self, src: Src) -> Self
Setter for the ‘properties’ field.
source§impl<Context, End> CommandFormer<Context, End>where
End: ToSuperFormer<Command, Context>,
impl<Context, End> CommandFormer<Context, End>where
End: ToSuperFormer<Command, Context>,
sourcepub fn property_alias<S: Into<String>>(self, key: S, alias: S) -> Self
pub fn property_alias<S: Into<String>>(self, key: S, alias: S) -> Self
Setter for separate properties aliases.
sourcepub fn routine<I, R, F: Into<Handler<I, R>>>(self, f: F) -> Self
pub fn routine<I, R, F: Into<Handler<I, R>>>(self, f: F) -> Self
Sets the command routine.
You can set the following types of command routines:
fn(): A command routine without any argument or property.fn(args): A command routine with arguments.fn(props): A command routine with properties.fn(args, props): A command routine with arguments and properties.fn(context): A command routine with a context.fn(context, args): A command routine with a context and arguments.fn(context, props): A command routine with a context and properties.fn(context, args, props): A command routine with a context, arguments, and properties.
§Type Parameters
I: The input type for the handler function.R: The return type for the handler function.F: The function type that can be converted into a handler.
§Parameters
self: The currentCommandFormerinstance. This instance will be consumed by this method.f: The function that will be set as the command routine.
§Returns
Returns the CommandFormer instance with the new command routine set.
source§impl<Context, End> CommandFormer<Context, End>where
End: ToSuperFormer<Command, Context>,
impl<Context, End> CommandFormer<Context, End>where
End: ToSuperFormer<Command, Context>,
sourcepub fn subject(
self
) -> ValueDescriptionFormer<Self, impl ToSuperFormer<ValueDescription, Self>>
pub fn subject( self ) -> ValueDescriptionFormer<Self, impl ToSuperFormer<ValueDescription, Self>>
Implements the subject method for a value.
This method allows chaining, where subject is the current value and ValueDescription is the super-former.
It returns a ValueDescriptionFormer which can be used to further build the super-former.
sourcepub fn property<IntoName>(
self,
name: IntoName
) -> PropertyDescriptionFormer<Self, impl ToSuperFormer<PropertyDescription, Self>>
pub fn property<IntoName>( self, name: IntoName ) -> PropertyDescriptionFormer<Self, impl ToSuperFormer<PropertyDescription, Self>>
Sets the name and other properties of the current property.
This method takes ownership of self and the name of the property as input.
It returns a PropertyDescriptionFormer instance that allows chaining of different property
descriptions.
§Arguments
name- The name of the property. It should implement theInto< String >trait.