Skip to main content

ContentPart

Enum ContentPart 

Source
#[non_exhaustive]
pub enum ContentPart { Text { text: String, }, Image { source: String, mime_type: String, data: Option<String>, }, Audio { source: String, mime_type: String, data: Option<String>, }, Video { source: String, mime_type: String, data: Option<String>, }, File { source: String, mime_type: String, data: Option<String>, }, ToolUse { id: String, name: String, input: Map<String, Value>, }, ToolResult { id: String, content: String, is_error: bool, }, }
Expand description

A single content part in a multimodal message.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Text

Plain text content.

Fields

§text: String

UTF-8 text.

§

Image

Image content by URL/source and optional inline data.

Fields

§source: String

Provider-readable source, such as a URL or media identifier.

§mime_type: String

MIME type, for example image/png.

§data: Option<String>

Optional base64-encoded data.

§

Audio

Audio content by URL/source and optional inline data.

Fields

§source: String

Provider-readable source, such as a URL or media identifier.

§mime_type: String

MIME type, for example audio/mpeg.

§data: Option<String>

Optional base64-encoded data.

§

Video

Video content by URL/source and optional inline data.

Fields

§source: String

Provider-readable source, such as a URL or media identifier.

§mime_type: String

MIME type, for example video/mp4.

§data: Option<String>

Optional base64-encoded data.

§

File

File content by URL/source and optional inline data.

Fields

§source: String

Provider-readable source, such as a URL or media identifier.

§mime_type: String

MIME type, for example application/pdf.

§data: Option<String>

Optional base64-encoded data.

§

ToolUse

Tool-use request block emitted by a model.

Fields

§id: String

Tool-use identifier.

§name: String

Tool name.

§input: Map<String, Value>

Tool input JSON.

§

ToolResult

Tool-result block returned to a model.

Fields

§id: String

Tool-use identifier this result satisfies.

§content: String

Human-readable content.

§is_error: bool

Whether the tool returned an error.

Implementations§

Source§

impl ContentPart

Source

pub fn approx_chars(&self) -> usize

Rough character estimate used by approximate token counters.

Trait Implementations§

Source§

impl Clone for ContentPart

Source§

fn clone(&self) -> ContentPart

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContentPart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ContentPart

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ContentPart

Source§

fn eq(&self, other: &ContentPart) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ContentPart

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ContentPart

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.