pub enum ContentBlock {
    TextContent(TextContent),
    ImageContent(ImageContent),
    AudioContent(AudioContent),
    ResourceLink(ResourceLink),
    EmbeddedResource(EmbeddedResource),
}Expand description
ContentBlock
JSON schema
{
 "anyOf": [
   {
     "$ref": "#/definitions/TextContent"
   },
   {
     "$ref": "#/definitions/ImageContent"
   },
   {
     "$ref": "#/definitions/AudioContent"
   },
   {
     "$ref": "#/definitions/ResourceLink"
   },
   {
     "$ref": "#/definitions/EmbeddedResource"
   }
 ]
}Variants§
TextContent(TextContent)
ImageContent(ImageContent)
AudioContent(AudioContent)
ResourceLink(ResourceLink)
EmbeddedResource(EmbeddedResource)
Implementations§
Source§impl ContentBlock
 
impl ContentBlock
Sourcepub fn text_content(text: String) -> Self
 
pub fn text_content(text: String) -> Self
Create a ContentBlock::TextContent
Sourcepub fn image_content(data: String, mime_type: String) -> Self
 
pub fn image_content(data: String, mime_type: String) -> Self
Create a ContentBlock::ImageContent
Sourcepub fn audio_content(data: String, mime_type: String) -> Self
 
pub fn audio_content(data: String, mime_type: String) -> Self
Create a ContentBlock::AudioContent
Sourcepub fn resource_link(value: ResourceLink) -> Self
 
pub fn resource_link(value: ResourceLink) -> Self
Create a ContentBlock::ResourceLink
Sourcepub fn embedded_resource(resource: EmbeddedResourceResource) -> Self
 
pub fn embedded_resource(resource: EmbeddedResourceResource) -> Self
Create a ContentBlock::EmbeddedResource
Sourcepub fn content_type(&self) -> &str
 
pub fn content_type(&self) -> &str
Returns the content type as a string based on the variant of ContentBlock
Sourcepub fn as_text_content(&self) -> Result<&TextContent, RpcError>
 
pub fn as_text_content(&self) -> Result<&TextContent, RpcError>
Converts the content to a reference to TextContent, returning an error if the conversion is invalid.
Sourcepub fn as_image_content(&self) -> Result<&ImageContent, RpcError>
 
pub fn as_image_content(&self) -> Result<&ImageContent, RpcError>
Converts the content to a reference to TextContent, returning an error if the conversion is invalid.
Sourcepub fn as_audio_content(&self) -> Result<&AudioContent, RpcError>
 
pub fn as_audio_content(&self) -> Result<&AudioContent, RpcError>
Converts the content to a reference to TextContent, returning an error if the conversion is invalid.
Sourcepub fn as_resource_link(&self) -> Result<&ResourceLink, RpcError>
 
pub fn as_resource_link(&self) -> Result<&ResourceLink, RpcError>
Converts the content to a reference to TextContent, returning an error if the conversion is invalid.
Sourcepub fn as_embedded_resource(&self) -> Result<&EmbeddedResource, RpcError>
 
pub fn as_embedded_resource(&self) -> Result<&EmbeddedResource, RpcError>
Converts the content to a reference to TextContent, returning an error if the conversion is invalid.
Trait Implementations§
Source§impl Clone for ContentBlock
 
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
 
fn clone(&self) -> ContentBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read more