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>,

source

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.

source

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.

source

pub fn new() -> CommandFormer<Command, 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 hint<Src>(self, src: Src) -> Self
where Src: Into<String>,

Setter for the ‘hint’ field.

source

pub fn h<Src>(self, src: Src) -> Self
where Src: Into<String>,

Setter for the ‘hint’ field.

source

pub fn long_hint<Src>(self, src: Src) -> Self
where Src: Into<String>,

Setter for the ‘long_hint’ field.

source

pub fn lh<Src>(self, src: Src) -> Self
where Src: Into<String>,

Setter for the ‘long_hint’ field.

source

pub fn phrase<Src>(self, src: Src) -> Self
where Src: Into<String>,

Setter for the ‘phrase’ field.

source

pub fn subjects<Src>(self, src: Src) -> Self
where Src: Into<Vec<ValueDescription>>,

Setter for the ‘subjects’ field.

source

pub fn properties<Src>(self, src: Src) -> Self

Setter for the ‘properties’ field.

source

pub fn properties_aliases<Src>(self, src: Src) -> Self
where Src: Into<HashMap<String, String>>,

Setter for the ‘properties_aliases’ field.

source§

impl<Context, End> CommandFormer<Context, End>
where End: ToSuperFormer<Command, Context>,

source

pub fn property_alias<S: Into<String>>(self, key: S, alias: S) -> Self

Setter for separate properties aliases.

source

pub fn routine<I, R, F: Into<Handler<I, R>>>(self, f: F) -> Self
where Routine: From<Handler<I, R>>,

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 current CommandFormer instance. 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>,

source

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.

source

pub fn property<IntoName>( self, name: IntoName ) -> PropertyDescriptionFormer<Self, impl ToSuperFormer<PropertyDescription, Self>>
where IntoName: Into<String>,

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 the Into< String > trait.

Auto Trait Implementations§

§

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

§

impl<__FormerContext = Command, __FormerEnd = ReturnContainer> !RefUnwindSafe for CommandFormer<__FormerContext, __FormerEnd>

§

impl<__FormerContext = Command, __FormerEnd = ReturnContainer> !Send for CommandFormer<__FormerContext, __FormerEnd>

§

impl<__FormerContext = Command, __FormerEnd = ReturnContainer> !Sync for CommandFormer<__FormerContext, __FormerEnd>

§

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

§

impl<__FormerContext = Command, __FormerEnd = ReturnContainer> !UnwindSafe for CommandFormer<__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,