Crate peace_params

source ·
Expand description

Constraints and specifications for parameters for the peace automation framework.

This crate defines types and traits for implementors and users to work with item params.

§Design

When an item is defined, implementors define the parameters type for that item.

For Peace to derive additional functionality from that type, this crate:

  • Defines the Params trait to bridge between the parameters type and associated types.
  • Re-exports the Params derive macro which implements the Params trait.

§How It Fits Together

.----------------------------------------------------------------------------------.
:          Users             :         Implementors           :       Peace        :
:----------------------------:--------------------------------:--------------------:
:                            :                                :                    :
:                            :   .-------------------.        :                    :
:                            :   | #[derive(Params)] |        : ---.               :
:                            :   | struct MyParams;  |        :    |               :
:                            :   '-------------------'        :    '               :
:                            :                                :  proc macro        :
:                            : .----------------------------. :  generates         :
:                            : | * MyParamsFieldWise        | :    .               :
:                            : | * MyParamsPartial          | :    |               :
:                            : | * MyParamsFieldWiseBuilder | : <--'               :
:                            : | * impl Params for MyParams | :                    :
:                            : '----------------------------' :                    :
:                            :                                :                    :
:                            :   .-------------------.        :                    :
:                            :   | struct MyItem;    |        :                    :
:                            :   |                   |        : ---.               :
:                            :   | impl Item for     |        :    |               :
:                            :   |   MyItem {        |        :    |               :
:                            :   |     type Params = |        :    '               :
:                            :   |     MyParams;     |        :  exposes API       :
:                            :   | }                 |        :  with constraints  :
:                            :   '-------------------'        :  from              :
:                            :                                :  <Item::Params     :
: .------------------------. :                                :    as Params>      :
: | cmd_ctx_builder        | :                                :    .               :
: | .with_item_params      | <-------------------------------------'               :
: |    ::<IS>(             | :                                :                    :
: |     item_id,           | :                                :                    :
: |     my_p_spec_builder  | :                                :                    :
: |       .with_f(123)     | :                                :                    :
: |       .with_from(..)   | :                                :                    :
: |     /* .build() */     | :                                :                    :
: |   )                    | :                                :                    :
: '------------------------' :                                :                    :
:                            :                                :                    :
'----------------------------------------------------------------------------------'

Re-exports§

Macros§

Structs§

Enums§

  • Failed to resolve values for a Params object from resources.
  • How to populate a field’s value in an item’s params.
  • Exists to deserialize MappingFn with a non-type-erased MappingFnImpl
  • How to populate a field’s value in an item’s params.
  • Exists to deserialize MappingFn with a non-type-erased MappingFnImpl
  • When resolving Values, whether to look up Current<T> or Goal<T>.
  • How to populate a field’s value in an item’s params.
  • Exists to deserialize MappingFn with a non-type-erased MappingFnImpl

Traits§

  • A [DataType] that is also an AnySpecRt.
  • Runtime logic of how to look up values for each field in this struct.
  • Runtime logic of how to look up values for each field in this struct.
  • Provides a simpler constraint for the compiler to report to the developer.
  • Provides a simpler constraint for the compiler to report to the developer.
  • Type erased mapping function.
  • Input parameters to an item.
  • Field of an Item::Params.
  • Runtime logic of how to look up values for each field in this struct.

Derive Macros§

  • Used to #[derive] the ValueSpec and ValueSpecRt traits.
  • Used to #[derive] the ParamsSpecFieldless and ValueSpecRt traits.