pub trait Elicitation:
Sized
+ Prompt
+ 'static {
type Style: Elicitation + Default + Clone + Send + Sync + 'static;
// Required method
fn elicit(
client: &ElicitClient<'_>,
) -> impl Future<Output = ElicitResult<Self>> + Send;
// Provided methods
fn with_style(style: Self::Style) -> ElicitBuilder<Self> { ... }
fn elicit_proven(
client: &ElicitClient<'_>,
) -> impl Future<Output = ElicitResult<(Self, Established<Is<Self>>)>> + Send { ... }
}Expand description
Main elicitation trait - entry point for value elicitation.
This trait defines how to elicit a value of a given type from the user via MCP (Model Context Protocol). All types that can be elicited implement this trait.
§Associated Types
Style- The style enum for this type. Each type has its own style enum that controls how prompts are presented. The style enum itself implementsElicitation, allowing automatic style selection.
§Example
use elicitation::{Elicitation, ElicitClient, ElicitResult};
// Elicit an i32 from the user
let value: i32 = i32::elicit(client).await?;Required Associated Types§
Sourcetype Style: Elicitation + Default + Clone + Send + Sync + 'static
type Style: Elicitation + Default + Clone + Send + Sync + 'static
The style enum for this type.
Controls how prompts are presented. For types with multiple styles,
this enum has variants for each style. For types with no custom styles,
this enum has only a Default variant.
The style enum itself implements Elicitation (using the Select pattern),
enabling automatic style selection when no style is pre-set.
Required Methods§
Sourcefn elicit(
client: &ElicitClient<'_>,
) -> impl Future<Output = ElicitResult<Self>> + Send
fn elicit( client: &ElicitClient<'_>, ) -> impl Future<Output = ElicitResult<Self>> + Send
Elicit a value of this type from the user via style-aware client.
§Arguments
client- The style-aware client wrapper to use for interaction
§Returns
Returns Ok(Self) if elicitation succeeds, or Err(ElicitError) if:
- The user provides invalid input
- The MCP tool call fails
- The user cancels the operation
§Errors
See ElicitError for details on error conditions.
Provided Methods§
Sourcefn with_style(style: Self::Style) -> ElicitBuilder<Self>
fn with_style(style: Self::Style) -> ElicitBuilder<Self>
Create a builder for one-off style override.
This enables ergonomic syntax for eliciting a value with a specific style without manually creating a styled client.
§Arguments
style- The style to use for this elicitation
§Returns
Returns an ElicitBuilder that can be used to elicit the value.
§Example
use elicitation::Elicitation;
// One-off style override - concise syntax
let config = Config::with_style(ConfigStyle::Curt)
.elicit(&peer)
.await?;Sourcefn elicit_proven(
client: &ElicitClient<'_>,
) -> impl Future<Output = ElicitResult<(Self, Established<Is<Self>>)>> + Send
fn elicit_proven( client: &ElicitClient<'_>, ) -> impl Future<Output = ElicitResult<(Self, Established<Is<Self>>)>> + Send
Elicit a value with proof it inhabits type Self.
After successful elicitation, returns both the value and a proof
that the value inhabits type Self. This proof can be carried
forward to downstream functions requiring guarantees.
§Returns
Returns Ok((value, proof)) where proof is Established<Is<Self>>.
§Example
use elicitation::{Elicitation, contracts::{Established, Is}};
// Elicit with proof
let (email, proof): (String, Established<Is<String>>) =
String::elicit_proven(client).await?;
// Use proof in downstream function
send_email(email, proof).await?;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.