elicitation_derive
Derive macros for the elicitation library.
This crate provides procedural macros for automatically implementing elicitation traits on custom types. It's typically used through the main elicitation crate.
Features
#[derive(Elicit)]- Automatic implementation of elicitation traits- Enum Support - Generates
Selectpattern for unit variant enums - Struct Support - Generates
Surveypattern for structs - Attribute Support -
#[prompt("...")],#[skip], and more
Usage
Add this to your Cargo.toml:
[]
= "0.2"
The derive macro is re-exported through the main crate:
use Elicit;
Attributes
#[prompt("...")]
Customize the prompt text for types or fields:
#[skip]
Skip a field during elicitation (uses Default::default()):
use ;
Generated Implementations
For Enums (Select Pattern)
Generates:
impl Prompt for Statusimpl Select for Statusimpl Elicitation for Status
For Structs (Survey Pattern)
Generates:
impl Prompt for Personimpl Survey for Personimpl Elicitation for Person
Requirements
- Enum variants must be unit variants (no fields) in v0.2.0
- Struct fields must implement
Elicitation - Struct must implement
Defaultif using#[skip]attribute
Version History
See CHANGELOG.md for version history.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.