@@ -587,6 +587,7 @@ impl FromStr for ClientJsonrpcResponse {
587587#[ serde( untagged) ]
588588pub enum ResultFromClient {
589589 ClientResult ( ClientResult ) ,
590+ #[ deprecated( since = "0.1.8" , note = "Use `ClientResult::Result` with extra attributes instead." ) ]
590591 CustomResult ( serde_json:: Value ) ,
591592}
592593
@@ -1106,6 +1107,7 @@ impl FromStr for ServerJsonrpcResponse {
11061107#[ serde( untagged) ]
11071108pub enum ResultFromServer {
11081109 ServerResult ( ServerResult ) ,
1110+ #[ deprecated( since = "0.1.8" , note = "Use `ServerResult::Result` with extra attributes instead." ) ]
11091111 CustomResult ( serde_json:: Value ) ,
11101112}
11111113
@@ -1504,26 +1506,6 @@ impl CallToolResult {
15041506 }
15051507}
15061508
1507- //**************************************//
1508- //** CallToolResultContentItem Impl **//
1509- //**************************************//
1510- impl CallToolResultContentItem {
1511- /// Create a `CallToolResultContentItem` with text content and optional annotations
1512- pub fn text_content ( test_content : String , annotations : Option < TextContentAnnotations > ) -> Self {
1513- TextContent :: new ( annotations, test_content) . into ( )
1514- }
1515-
1516- /// Create a `CallToolResultContentItem` with image content, with data, MIME type, and optional annotations
1517- pub fn image_content ( data : String , mime_type : String , annotations : Option < ImageContentAnnotations > ) -> Self {
1518- ImageContent :: new ( annotations, data, mime_type) . into ( )
1519- }
1520-
1521- /// Create a `CallToolResultContentItem` with an embedded resource, with optional annotations
1522- pub fn embedded_resource ( resource : EmbeddedResourceResource , annotations : Option < EmbeddedResourceAnnotations > ) -> Self {
1523- EmbeddedResource :: new ( annotations, resource) . into ( )
1524- }
1525- }
1526-
15271509/// BEGIN AUTO GENERATED
15281510impl :: serde:: Serialize for ClientJsonrpcRequest {
15291511 fn serialize < S > ( & self , serializer : S ) -> std:: result:: Result < S :: Ok , S :: Error >
@@ -3682,6 +3664,77 @@ impl TryFrom<NotificationFromServer> for LoggingMessageNotification {
36823664 }
36833665 }
36843666}
3667+ impl CallToolResultContentItem {
3668+ /// Create a `CallToolResultContentItem` with text content and optional annotations
3669+ pub fn text_content ( text_content : String , annotations : Option < TextContentAnnotations > ) -> Self {
3670+ TextContent :: new ( annotations, text_content) . into ( )
3671+ }
3672+ /// Create a `CallToolResultContentItem` with image content, with data, MIME type, and optional annotations
3673+ pub fn image_content ( data : String , mime_type : String , annotations : Option < ImageContentAnnotations > ) -> Self {
3674+ ImageContent :: new ( annotations, data, mime_type) . into ( )
3675+ }
3676+ /// Create a `CallToolResultContentItem` with an audio content resource and mime_type with optional annotations
3677+ pub fn audio_content ( data : String , mime_type : String , annotations : Option < AudioContentAnnotations > ) -> Self {
3678+ AudioContent :: new ( annotations, data, mime_type) . into ( )
3679+ }
3680+ /// Create a `CallToolResultContentItem` with an embedded resource, with optional annotations
3681+ pub fn embedded_resource ( resource : EmbeddedResourceResource , annotations : Option < EmbeddedResourceAnnotations > ) -> Self {
3682+ EmbeddedResource :: new ( annotations, resource) . into ( )
3683+ }
3684+ /// Returns the content type as a string based on the variant of `CallToolResultContentItem`.
3685+ pub fn content_type ( & self ) -> & str {
3686+ match self {
3687+ CallToolResultContentItem :: TextContent ( text_content) => text_content. type_ ( ) ,
3688+ CallToolResultContentItem :: ImageContent ( image_content) => image_content. type_ ( ) ,
3689+ CallToolResultContentItem :: AudioContent ( audio_content) => audio_content. type_ ( ) ,
3690+ CallToolResultContentItem :: EmbeddedResource ( embedded_resource) => embedded_resource. type_ ( ) ,
3691+ }
3692+ }
3693+ /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid.
3694+ pub fn as_text_content ( & self ) -> std:: result:: Result < & TextContent , JsonrpcErrorError > {
3695+ match & self {
3696+ CallToolResultContentItem :: TextContent ( text_content) => Ok ( text_content) ,
3697+ _ => Err ( JsonrpcErrorError :: internal_error ( ) . with_message ( format ! (
3698+ "Invalid conversion, \" {}\" is not a {}" ,
3699+ self . content_type( ) ,
3700+ "TextContent"
3701+ ) ) ) ,
3702+ }
3703+ }
3704+ /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid.
3705+ pub fn as_image_content ( & self ) -> std:: result:: Result < & ImageContent , JsonrpcErrorError > {
3706+ match & self {
3707+ CallToolResultContentItem :: ImageContent ( image_content) => Ok ( image_content) ,
3708+ _ => Err ( JsonrpcErrorError :: internal_error ( ) . with_message ( format ! (
3709+ "Invalid conversion, \" {}\" is not a {}" ,
3710+ self . content_type( ) ,
3711+ "ImageContent"
3712+ ) ) ) ,
3713+ }
3714+ }
3715+ /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid.
3716+ pub fn as_audio_content ( & self ) -> std:: result:: Result < & AudioContent , JsonrpcErrorError > {
3717+ match & self {
3718+ CallToolResultContentItem :: AudioContent ( audio_content) => Ok ( audio_content) ,
3719+ _ => Err ( JsonrpcErrorError :: internal_error ( ) . with_message ( format ! (
3720+ "Invalid conversion, \" {}\" is not a {}" ,
3721+ self . content_type( ) ,
3722+ "AudioContent"
3723+ ) ) ) ,
3724+ }
3725+ }
3726+ /// Converts the content to a reference to `TextContent`, returning an error if the conversion is invalid.
3727+ pub fn as_embedded_resource ( & self ) -> std:: result:: Result < & EmbeddedResource , JsonrpcErrorError > {
3728+ match & self {
3729+ CallToolResultContentItem :: EmbeddedResource ( embedded_resource) => Ok ( embedded_resource) ,
3730+ _ => Err ( JsonrpcErrorError :: internal_error ( ) . with_message ( format ! (
3731+ "Invalid conversion, \" {}\" is not a {}" ,
3732+ self . content_type( ) ,
3733+ "EmbeddedResource"
3734+ ) ) ) ,
3735+ }
3736+ }
3737+ }
36853738/// END AUTO GENERATED
36863739#[ cfg( test) ]
36873740mod tests {
0 commit comments