pub trait Select: Prompt + Sized {
// Required methods
fn options() -> &'static [Self];
fn labels() -> &'static [&'static str];
fn from_label(label: &str) -> Option<Self>;
}Expand description
Select one value from a finite set (dropdown/radio button pattern).
This trait represents the conversational equivalent of a dropdown menu or radio button group. It is the natural elicitation mode for enums and categorical fields.
§Example
use elicitation::{Select, Prompt};
#[derive(Debug, Clone, Copy)]
enum Color {
Red,
Green,
Blue,
}
impl Prompt for Color {
fn prompt() -> Option<&'static str> {
Some("Choose a color:")
}
}
impl Select for Color {
fn options() -> &'static [Self] {
&[Color::Red, Color::Green, Color::Blue]
}
fn labels() -> &'static [&'static str] {
&["Red", "Green", "Blue"]
}
fn from_label(label: &str) -> Option<Self> {
match label {
"Red" => Some(Color::Red),
"Green" => Some(Color::Green),
"Blue" => Some(Color::Blue),
_ => None,
}
}
}Required Methods§
Sourcefn options() -> &'static [Self]
fn options() -> &'static [Self]
All valid options for this selection.
Returns a static slice of all possible values. The MCP tool will ensure the user selects one of these options.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.