pub enum ToolContentPart {
Image {
source: ImageSource,
},
Text {
text: String,
},
}Expand description
A part of a Multipart ToolContent.
Represents a single piece of content within a multi-part tool result.
Currently supports images (via ImageSource) and text.
§Construction
Use text or image
constructors rather than building variants directly.
§Example
use loopctl::message::{ImageSource, ToolContent, ToolContentPart};
let text_part = ToolContentPart::text("Screenshot analysis:");
let img_part = ToolContentPart::image(ImageSource::new_base64("image/png", "..."));
let content = ToolContent::from_multipart(vec![text_part, img_part]);Variants§
Image
An image part within a Multipart tool result.
Contains the base64-encoded image data. Used by tools that capture screenshots or generate images.
Fields
source: ImageSourceThe image data and metadata.
See ImageSource for the structure and supported formats.
The ImageSource::encoding will always be "base64".
Text
A text part within a Multipart tool result.
Contains a plain text string.
Fields
text: StringThe text content of this part.
May contain multiple lines. Joined with other text parts
by ToolContent’s Display impl.
Implementations§
Source§impl ToolContentPart
impl ToolContentPart
Sourcepub fn text(text: impl Into<String>) -> Self
pub fn text(text: impl Into<String>) -> Self
Create a text part.
Constructor for the Text variant.
Use to build individual text segments within a
ToolContent::Multipart result.
§Arguments
text— The text content. Accepts any type that implementsInto<String>(e.g.&str,String).
§Returns
A ToolContentPart::Text variant.
§Example
use loopctl::message::{ToolContentPart};
let part = ToolContentPart::text("result: 42");Sourcepub const fn image(source: ImageSource) -> Self
pub const fn image(source: ImageSource) -> Self
Create an image part.
Use when a tool result includes image data alongside text.
Combine with ToolContentPart::text parts via
ToolContent::from_multipart to produce a multi-part
result containing both text and images.
§Arguments
source— TheImageSourcecontaining the image data. Construct withImageSource::new_base64.
§Returns
A ToolContentPart::Image variant.
§Example
use loopctl::message::{ImageSource, ToolContentPart};
let part = ToolContentPart::image(ImageSource::new_base64("image/png", "..."));Trait Implementations§
Source§impl Clone for ToolContentPart
impl Clone for ToolContentPart
Source§fn clone(&self) -> ToolContentPart
fn clone(&self) -> ToolContentPart
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolContentPart
impl Debug for ToolContentPart
Source§impl<'de> Deserialize<'de> for ToolContentPart
impl<'de> Deserialize<'de> for ToolContentPart
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>,
impl Eq for ToolContentPart
Source§impl PartialEq for ToolContentPart
impl PartialEq for ToolContentPart
Source§fn eq(&self, other: &ToolContentPart) -> bool
fn eq(&self, other: &ToolContentPart) -> bool
self and other values to be equal, and is used by ==.