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 theParams
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§
pub use tynm;
Macros§
Structs§
- Box of a [
DataType
] that is also a [ValueSpecRt
]. - A field name and its type.
- Wrapper around a mapping function so that it can be serialized.
- Map of item ID to its params’ specs.
TypeMap<ItemId, AnySpecRtBoxed>
newtype. - Collects information about how a value is resolved.
Enums§
- Failed to resolve values for a
Params
object fromresources
. - How to populate a field’s value in an item’s params.
- Exists to deserialize
MappingFn
with a non-type-erasedMappingFnImpl
- How to populate a field’s value in an item’s params.
- Exists to deserialize
MappingFn
with a non-type-erasedMappingFnImpl
- When resolving
Value
s, whether to look upCurrent<T>
orGoal<T>
. - How to populate a field’s value in an item’s params.
- Exists to deserialize
MappingFn
with a non-type-erasedMappingFnImpl
Traits§
- A [
DataType
] that is also anAnySpecRt
. - 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]
theValueSpec
andValueSpecRt
traits. - Used to
#[derive]
theParamsSpecFieldless
andValueSpecRt
traits.