pub struct ElicitationSchemaBuilder {
pub properties: BTreeMap<String, PrimitiveSchemaDefinition>,
pub required: Vec<String>,
pub title: Option<Cow<'static, str>>,
pub description: Option<Cow<'static, str>>,
}Expand description
Fluent builder for constructing elicitation schemas.
§Example
use rmcp::model::*;
let schema = ElicitationSchema::builder()
.required_email("email")
.required_integer("age", 0, 150)
.optional_bool("newsletter", false)
.description("User registration")
.build();Fields§
§properties: BTreeMap<String, PrimitiveSchemaDefinition>§required: Vec<String>§title: Option<Cow<'static, str>>§description: Option<Cow<'static, str>>Implementations§
Source§impl ElicitationSchemaBuilder
impl ElicitationSchemaBuilder
Sourcepub fn new() -> ElicitationSchemaBuilder
pub fn new() -> ElicitationSchemaBuilder
Create a new builder
Sourcepub fn property(
self,
name: impl Into<String>,
schema: PrimitiveSchemaDefinition,
) -> ElicitationSchemaBuilder
pub fn property( self, name: impl Into<String>, schema: PrimitiveSchemaDefinition, ) -> ElicitationSchemaBuilder
Add a property to the schema
Sourcepub fn required_property(
self,
name: impl Into<String>,
schema: PrimitiveSchemaDefinition,
) -> ElicitationSchemaBuilder
pub fn required_property( self, name: impl Into<String>, schema: PrimitiveSchemaDefinition, ) -> ElicitationSchemaBuilder
Add a required property to the schema
Sourcepub fn string_property(
self,
name: impl Into<String>,
f: impl FnOnce(StringSchema) -> StringSchema,
) -> ElicitationSchemaBuilder
pub fn string_property( self, name: impl Into<String>, f: impl FnOnce(StringSchema) -> StringSchema, ) -> ElicitationSchemaBuilder
Add a string property with custom builder (required)
Sourcepub fn required_string_property(
self,
name: impl Into<String>,
f: impl FnOnce(StringSchema) -> StringSchema,
) -> ElicitationSchemaBuilder
pub fn required_string_property( self, name: impl Into<String>, f: impl FnOnce(StringSchema) -> StringSchema, ) -> ElicitationSchemaBuilder
Add a required string property with custom builder
Sourcepub fn number_property(
self,
name: impl Into<String>,
f: impl FnOnce(NumberSchema) -> NumberSchema,
) -> ElicitationSchemaBuilder
pub fn number_property( self, name: impl Into<String>, f: impl FnOnce(NumberSchema) -> NumberSchema, ) -> ElicitationSchemaBuilder
Add a number property with custom builder
Sourcepub fn required_number_property(
self,
name: impl Into<String>,
f: impl FnOnce(NumberSchema) -> NumberSchema,
) -> ElicitationSchemaBuilder
pub fn required_number_property( self, name: impl Into<String>, f: impl FnOnce(NumberSchema) -> NumberSchema, ) -> ElicitationSchemaBuilder
Add a required number property with custom builder
Sourcepub fn integer_property(
self,
name: impl Into<String>,
f: impl FnOnce(IntegerSchema) -> IntegerSchema,
) -> ElicitationSchemaBuilder
pub fn integer_property( self, name: impl Into<String>, f: impl FnOnce(IntegerSchema) -> IntegerSchema, ) -> ElicitationSchemaBuilder
Add an integer property with custom builder
Sourcepub fn required_integer_property(
self,
name: impl Into<String>,
f: impl FnOnce(IntegerSchema) -> IntegerSchema,
) -> ElicitationSchemaBuilder
pub fn required_integer_property( self, name: impl Into<String>, f: impl FnOnce(IntegerSchema) -> IntegerSchema, ) -> ElicitationSchemaBuilder
Add a required integer property with custom builder
Sourcepub fn bool_property(
self,
name: impl Into<String>,
f: impl FnOnce(BooleanSchema) -> BooleanSchema,
) -> ElicitationSchemaBuilder
pub fn bool_property( self, name: impl Into<String>, f: impl FnOnce(BooleanSchema) -> BooleanSchema, ) -> ElicitationSchemaBuilder
Add a boolean property with custom builder
Sourcepub fn required_bool_property(
self,
name: impl Into<String>,
f: impl FnOnce(BooleanSchema) -> BooleanSchema,
) -> ElicitationSchemaBuilder
pub fn required_bool_property( self, name: impl Into<String>, f: impl FnOnce(BooleanSchema) -> BooleanSchema, ) -> ElicitationSchemaBuilder
Add a required boolean property with custom builder
Sourcepub fn required_string(
self,
name: impl Into<String>,
) -> ElicitationSchemaBuilder
pub fn required_string( self, name: impl Into<String>, ) -> ElicitationSchemaBuilder
Add a required string property
Sourcepub fn optional_string(
self,
name: impl Into<String>,
) -> ElicitationSchemaBuilder
pub fn optional_string( self, name: impl Into<String>, ) -> ElicitationSchemaBuilder
Add an optional string property
Sourcepub fn required_email(self, name: impl Into<String>) -> ElicitationSchemaBuilder
pub fn required_email(self, name: impl Into<String>) -> ElicitationSchemaBuilder
Add a required email property
Sourcepub fn optional_email(self, name: impl Into<String>) -> ElicitationSchemaBuilder
pub fn optional_email(self, name: impl Into<String>) -> ElicitationSchemaBuilder
Add an optional email property
Sourcepub fn required_string_with(
self,
name: impl Into<String>,
f: impl FnOnce(StringSchema) -> StringSchema,
) -> ElicitationSchemaBuilder
pub fn required_string_with( self, name: impl Into<String>, f: impl FnOnce(StringSchema) -> StringSchema, ) -> ElicitationSchemaBuilder
Add a required string property with custom builder
Sourcepub fn optional_string_with(
self,
name: impl Into<String>,
f: impl FnOnce(StringSchema) -> StringSchema,
) -> ElicitationSchemaBuilder
pub fn optional_string_with( self, name: impl Into<String>, f: impl FnOnce(StringSchema) -> StringSchema, ) -> ElicitationSchemaBuilder
Add an optional string property with custom builder
Sourcepub fn required_number(
self,
name: impl Into<String>,
min: f64,
max: f64,
) -> ElicitationSchemaBuilder
pub fn required_number( self, name: impl Into<String>, min: f64, max: f64, ) -> ElicitationSchemaBuilder
Add a required number property with range
Sourcepub fn optional_number(
self,
name: impl Into<String>,
min: f64,
max: f64,
) -> ElicitationSchemaBuilder
pub fn optional_number( self, name: impl Into<String>, min: f64, max: f64, ) -> ElicitationSchemaBuilder
Add an optional number property with range
Sourcepub fn required_number_with(
self,
name: impl Into<String>,
f: impl FnOnce(NumberSchema) -> NumberSchema,
) -> ElicitationSchemaBuilder
pub fn required_number_with( self, name: impl Into<String>, f: impl FnOnce(NumberSchema) -> NumberSchema, ) -> ElicitationSchemaBuilder
Add a required number property with custom builder
Sourcepub fn optional_number_with(
self,
name: impl Into<String>,
f: impl FnOnce(NumberSchema) -> NumberSchema,
) -> ElicitationSchemaBuilder
pub fn optional_number_with( self, name: impl Into<String>, f: impl FnOnce(NumberSchema) -> NumberSchema, ) -> ElicitationSchemaBuilder
Add an optional number property with custom builder
Sourcepub fn required_integer(
self,
name: impl Into<String>,
min: i64,
max: i64,
) -> ElicitationSchemaBuilder
pub fn required_integer( self, name: impl Into<String>, min: i64, max: i64, ) -> ElicitationSchemaBuilder
Add a required integer property with range
Sourcepub fn optional_integer(
self,
name: impl Into<String>,
min: i64,
max: i64,
) -> ElicitationSchemaBuilder
pub fn optional_integer( self, name: impl Into<String>, min: i64, max: i64, ) -> ElicitationSchemaBuilder
Add an optional integer property with range
Sourcepub fn required_integer_with(
self,
name: impl Into<String>,
f: impl FnOnce(IntegerSchema) -> IntegerSchema,
) -> ElicitationSchemaBuilder
pub fn required_integer_with( self, name: impl Into<String>, f: impl FnOnce(IntegerSchema) -> IntegerSchema, ) -> ElicitationSchemaBuilder
Add a required integer property with custom builder
Sourcepub fn optional_integer_with(
self,
name: impl Into<String>,
f: impl FnOnce(IntegerSchema) -> IntegerSchema,
) -> ElicitationSchemaBuilder
pub fn optional_integer_with( self, name: impl Into<String>, f: impl FnOnce(IntegerSchema) -> IntegerSchema, ) -> ElicitationSchemaBuilder
Add an optional integer property with custom builder
Sourcepub fn required_bool(self, name: impl Into<String>) -> ElicitationSchemaBuilder
pub fn required_bool(self, name: impl Into<String>) -> ElicitationSchemaBuilder
Add a required boolean property
Sourcepub fn optional_bool(
self,
name: impl Into<String>,
default: bool,
) -> ElicitationSchemaBuilder
pub fn optional_bool( self, name: impl Into<String>, default: bool, ) -> ElicitationSchemaBuilder
Add an optional boolean property with default value
Sourcepub fn required_bool_with(
self,
name: impl Into<String>,
f: impl FnOnce(BooleanSchema) -> BooleanSchema,
) -> ElicitationSchemaBuilder
pub fn required_bool_with( self, name: impl Into<String>, f: impl FnOnce(BooleanSchema) -> BooleanSchema, ) -> ElicitationSchemaBuilder
Add a required boolean property with custom builder
Sourcepub fn optional_bool_with(
self,
name: impl Into<String>,
f: impl FnOnce(BooleanSchema) -> BooleanSchema,
) -> ElicitationSchemaBuilder
pub fn optional_bool_with( self, name: impl Into<String>, f: impl FnOnce(BooleanSchema) -> BooleanSchema, ) -> ElicitationSchemaBuilder
Add an optional boolean property with custom builder
Sourcepub fn required_enum_schema(
self,
name: impl Into<String>,
enum_schema: EnumSchema,
) -> ElicitationSchemaBuilder
pub fn required_enum_schema( self, name: impl Into<String>, enum_schema: EnumSchema, ) -> ElicitationSchemaBuilder
Add a required enum property using EnumSchema
Sourcepub fn optional_enum_schema(
self,
name: impl Into<String>,
enum_schema: EnumSchema,
) -> ElicitationSchemaBuilder
pub fn optional_enum_schema( self, name: impl Into<String>, enum_schema: EnumSchema, ) -> ElicitationSchemaBuilder
Add an optional enum property using EnumSchema
Sourcepub fn mark_required(self, name: impl Into<String>) -> ElicitationSchemaBuilder
pub fn mark_required(self, name: impl Into<String>) -> ElicitationSchemaBuilder
Mark an existing property as required
Sourcepub fn title(
self,
title: impl Into<Cow<'static, str>>,
) -> ElicitationSchemaBuilder
pub fn title( self, title: impl Into<Cow<'static, str>>, ) -> ElicitationSchemaBuilder
Set the schema title
Sourcepub fn description(
self,
description: impl Into<Cow<'static, str>>,
) -> ElicitationSchemaBuilder
pub fn description( self, description: impl Into<Cow<'static, str>>, ) -> ElicitationSchemaBuilder
Set the schema description
Sourcepub fn build(self) -> Result<ElicitationSchema, &'static str>
pub fn build(self) -> Result<ElicitationSchema, &'static str>
Build the elicitation schema with validation
§Errors
Returns an error if:
- Required fields reference non-existent properties
- No properties are defined (empty schema)
Sourcepub fn build_unchecked(self) -> ElicitationSchema
pub fn build_unchecked(self) -> ElicitationSchema
Build the elicitation schema without validation (panics on invalid schema)
§Panics
Panics if required fields reference non-existent properties
Trait Implementations§
Source§impl Debug for ElicitationSchemaBuilder
impl Debug for ElicitationSchemaBuilder
Source§impl Default for ElicitationSchemaBuilder
impl Default for ElicitationSchemaBuilder
Source§fn default() -> ElicitationSchemaBuilder
fn default() -> ElicitationSchemaBuilder
Auto Trait Implementations§
impl Freeze for ElicitationSchemaBuilder
impl RefUnwindSafe for ElicitationSchemaBuilder
impl Send for ElicitationSchemaBuilder
impl Sync for ElicitationSchemaBuilder
impl Unpin for ElicitationSchemaBuilder
impl UnsafeUnpin for ElicitationSchemaBuilder
impl UnwindSafe for ElicitationSchemaBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more