#[non_exhaustive]pub enum ContentPart {
Text {
text: String,
},
Image {
image: ImageSource,
},
Document {
document: DocumentSource,
},
}Expand description
A single part of a user-visible or tool-result content array.
Provider-neutral. The motosan-ai adapter translates these into
motosan_ai::types::ContentBlock at dispatch time.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Text
Plain UTF-8 text.
Image
An image, provided inline or by URL.
Fields
image: ImageSourceDocument
A document (e.g. PDF), provided inline or by URL.
Fields
document: DocumentSourceImplementations§
Source§impl ContentPart
impl ContentPart
Sourcepub fn text(s: impl Into<String>) -> ContentPart
pub fn text(s: impl Into<String>) -> ContentPart
Convenience constructor for the common text case.
Sourcepub fn image_base64(
media_type: impl Into<String>,
data: impl Into<String>,
) -> ContentPart
pub fn image_base64( media_type: impl Into<String>, data: impl Into<String>, ) -> ContentPart
Convenience constructor for a base64-encoded image.
Sourcepub fn image_url(url: impl Into<String>) -> ContentPart
pub fn image_url(url: impl Into<String>) -> ContentPart
Convenience constructor for a URL image.
Sourcepub fn document_base64(
media_type: impl Into<String>,
data: impl Into<String>,
) -> ContentPart
pub fn document_base64( media_type: impl Into<String>, data: impl Into<String>, ) -> ContentPart
Convenience constructor for a base64-encoded document.
Sourcepub fn document_url(url: impl Into<String>) -> ContentPart
pub fn document_url(url: impl Into<String>) -> ContentPart
Convenience constructor for a URL document.
Sourcepub fn pdf_base64(data: impl Into<String>) -> ContentPart
pub fn pdf_base64(data: impl Into<String>) -> ContentPart
Convenience constructor for a base64-encoded PDF (media type fixed to application/pdf).
Sourcepub fn pdf_url(url: impl Into<String>) -> ContentPart
pub fn pdf_url(url: impl Into<String>) -> ContentPart
Convenience constructor for a PDF URL.
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
If this part is a Text, return its string. Non-text variants return None.
Sourcepub fn as_image(&self) -> Option<&ImageSource>
pub fn as_image(&self) -> Option<&ImageSource>
If this part is an Image, return its source.
Sourcepub fn as_document(&self) -> Option<&DocumentSource>
pub fn as_document(&self) -> Option<&DocumentSource>
If this part is a Document, return its source.
Trait Implementations§
Source§impl Clone for ContentPart
impl Clone for ContentPart
Source§fn clone(&self) -> ContentPart
fn clone(&self) -> ContentPart
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 ContentPart
impl Debug for ContentPart
Source§impl<'de> Deserialize<'de> for ContentPart
impl<'de> Deserialize<'de> for ContentPart
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentPart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentPart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ContentPart
impl PartialEq for ContentPart
Source§fn eq(&self, other: &ContentPart) -> bool
fn eq(&self, other: &ContentPart) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ContentPart
impl Serialize for ContentPart
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for ContentPart
impl StructuralPartialEq for ContentPart
Auto Trait Implementations§
impl Freeze for ContentPart
impl RefUnwindSafe for ContentPart
impl Send for ContentPart
impl Sync for ContentPart
impl Unpin for ContentPart
impl UnsafeUnpin for ContentPart
impl UnwindSafe for ContentPart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.