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) -> ContentBlock
pub fn text_content(text: String) -> ContentBlock
Create a ContentBlock::TextContent
Sourcepub fn image_content(data: String, mime_type: String) -> ContentBlock
pub fn image_content(data: String, mime_type: String) -> ContentBlock
Create a ContentBlock::ImageContent
Sourcepub fn audio_content(data: String, mime_type: String) -> ContentBlock
pub fn audio_content(data: String, mime_type: String) -> ContentBlock
Create a ContentBlock::AudioContent
Sourcepub fn resource_link(value: ResourceLink) -> ContentBlock
pub fn resource_link(value: ResourceLink) -> ContentBlock
Create a ContentBlock::ResourceLink
Sourcepub fn embedded_resource(resource: EmbeddedResourceResource) -> ContentBlock
pub fn embedded_resource(resource: EmbeddedResourceResource) -> ContentBlock
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§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more