pub enum ContentBlock {
TextContent(TextContent),
ImageContent(ImageContent),
AudioContent(AudioContent),
ResourceLink(ResourceLink),
EmbeddedResource(EmbeddedResource),
}Expand description
ContentBlock
JSON schema
{
"anyOf": [
{
"$ref": "#/$defs/TextContent"
},
{
"$ref": "#/$defs/ImageContent"
},
{
"$ref": "#/$defs/AudioContent"
},
{
"$ref": "#/$defs/ResourceLink"
},
{
"$ref": "#/$defs/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§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentBlock
impl Debug for ContentBlock
Source§impl<'de> Deserialize<'de> for ContentBlock
impl<'de> Deserialize<'de> for ContentBlock
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<AudioContent> for ContentBlock
impl From<AudioContent> for ContentBlock
Source§fn from(value: AudioContent) -> Self
fn from(value: AudioContent) -> Self
Source§impl From<EmbeddedResource> for ContentBlock
impl From<EmbeddedResource> for ContentBlock
Source§fn from(value: EmbeddedResource) -> Self
fn from(value: EmbeddedResource) -> Self
Source§impl From<ImageContent> for ContentBlock
impl From<ImageContent> for ContentBlock
Source§fn from(value: ImageContent) -> Self
fn from(value: ImageContent) -> Self
Source§impl From<ResourceLink> for ContentBlock
impl From<ResourceLink> for ContentBlock
Source§fn from(value: ResourceLink) -> Self
fn from(value: ResourceLink) -> Self
Source§impl From<TextContent> for ContentBlock
impl From<TextContent> for ContentBlock
Source§fn from(value: TextContent) -> Self
fn from(value: TextContent) -> Self
Auto Trait Implementations§
impl Freeze for ContentBlock
impl RefUnwindSafe for ContentBlock
impl Send for ContentBlock
impl Sync for ContentBlock
impl Unpin for ContentBlock
impl UnwindSafe for ContentBlock
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)