@@ -587,6 +587,7 @@ impl FromStr for ClientJsonrpcResponse {
587
587
#[ serde( untagged) ]
588
588
pub enum ResultFromClient {
589
589
ClientResult ( ClientResult ) ,
590
+ #[ deprecated( since = "0.1.8" , note = "Use `ClientResult::Result` with extra attributes instead." ) ]
590
591
CustomResult ( serde_json:: Value ) ,
591
592
}
592
593
@@ -1106,6 +1107,7 @@ impl FromStr for ServerJsonrpcResponse {
1106
1107
#[ serde( untagged) ]
1107
1108
pub enum ResultFromServer {
1108
1109
ServerResult ( ServerResult ) ,
1110
+ #[ deprecated( since = "0.1.8" , note = "Use `ServerResult::Result` with extra attributes instead." ) ]
1109
1111
CustomResult ( serde_json:: Value ) ,
1110
1112
}
1111
1113
@@ -1504,26 +1506,6 @@ impl CallToolResult {
1504
1506
}
1505
1507
}
1506
1508
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
-
1527
1509
/// BEGIN AUTO GENERATED
1528
1510
impl :: serde:: Serialize for ClientJsonrpcRequest {
1529
1511
fn serialize < S > ( & self , serializer : S ) -> std:: result:: Result < S :: Ok , S :: Error >
@@ -3682,6 +3664,77 @@ impl TryFrom<NotificationFromServer> for LoggingMessageNotification {
3682
3664
}
3683
3665
}
3684
3666
}
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
+ }
3685
3738
/// END AUTO GENERATED
3686
3739
#[ cfg( test) ]
3687
3740
mod tests {
0 commit comments