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§
- AnySpec
RtBoxed - Box of a
DataType
that is also a [ValueSpecRt
]. - Field
Name AndType - A field name and its type.
- Mapping
FnImpl - Wrapper around a mapping function so that it can be serialized.
- Params
Specs - Map of item ID to its params’ specs.
TypeMap<ItemId, AnySpecRtBoxed>
newtype. - Value
Resolution Ctx - Collects information about how a value is resolved.
Enums§
- Params
Resolve Error - Failed to resolve values for a
Params
object fromresources
. - Params
Spec - How to populate a field’s value in an item’s params.
- Params
Spec De - Exists to deserialize
MappingFn
with a non-type-erasedMappingFnImpl
- Params
Spec Fieldless - How to populate a field’s value in an item’s params.
- Params
Spec Fieldless De - Exists to deserialize
MappingFn
with a non-type-erasedMappingFnImpl
- Value
Resolution Mode - When resolving
Value
s, whether to look upCurrent<T>
orGoal<T>
. - Value
Spec - How to populate a field’s value in an item’s params.
- Value
Spec De - Exists to deserialize
MappingFn
with a non-type-erasedMappingFnImpl
Traits§
- AnySpec
Data Type - A
DataType
that is also anAnySpecRt
. - AnySpec
Rt - Runtime logic of how to look up values for each field in this struct.
- Field
Wise Spec Rt - Runtime logic of how to look up values for each field in this struct.
- From
Func - Provides a simpler constraint for the compiler to report to the developer.
- Func
- Provides a simpler constraint for the compiler to report to the developer.
- Mapping
Fn - Type erased mapping function.
- Params
- Input parameters to an item.
- Params
Fieldless - Field of an
Item::Params
. - Params
Key - Marker trait for a parameter key type.
- Params
Merge Ext - Trait for merging
ParamsPartial
onto aParams
object. - Params
Value - Marker trait for a parameter value type.
- Value
Spec Rt - Runtime logic of how to look up values for each field in this struct.
Derive Macros§
- Params
- Used to
#[derive]
theValueSpec
andValueSpecRt
traits. - Params
Fieldless - Used to
#[derive]
theParamsSpecFieldless
andValueSpecRt
traits.