Expand description
Derive macros for elicitation patterns.
This crate provides the #[derive(Elicit)] macro for automatically
implementing elicitation traits on enums and structs.
§Enum Derivation (Select Pattern)
§Unit Variants (Simple Selection)
ⓘ
use elicitation::Elicit;
#[derive(Elicit)]
enum Mode {
Fast,
Safe,
}User sees: “Fast”, “Safe” - single selection.
§Tuple Variants (Select + Field Elicitation)
ⓘ
use elicitation::Elicit;
#[derive(Elicit)]
enum MediaSource {
Url(String),
Base64(String),
}User: 1) Selects “Url” or “Base64”, 2) Provides String value.
§Struct Variants (Select + Multi-Field Survey)
ⓘ
use elicitation::Elicit;
#[derive(Elicit)]
enum Input {
Image {
mime: Option<String>,
source: MediaSource,
},
}User: 1) Selects “Image”, 2) Provides each field (mime, then source).
§Mixed Variants
All three variant types can appear in the same enum:
ⓘ
use elicitation::Elicit;
#[derive(Elicit)]
enum Status {
Ok, // Unit variant
Warning(String), // Tuple variant
Error { code: i32, msg: String }, // Struct variant
}§Struct Derivation (Survey Pattern)
ⓘ
use elicitation::Elicit;
// Derives Survey pattern for structs
#[derive(Elicit)]
struct Config {
#[prompt("Enter timeout in seconds:")]
timeout: u32,
mode: Mode,
}Attribute Macros§
- contract_
type - Annotates a type with verification contract metadata.
Derive Macros§
- Elicit
- Derive the Elicit trait for enums (→ Select) or structs (→ Survey).