#[non_exhaustive]pub enum ContentPart {
Text {
text: String,
},
Blob {
mime_type: String,
data: Vec<u8>,
name: Option<String>,
},
Uri {
mime_type: String,
uri: String,
name: Option<String>,
},
}Expand description
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
Prose.
Blob
Bytes carried in the request itself, with the MIME type that says how to read them.
Every provider caps how much it will take this way (a few megabytes);
past that the file belongs behind a Uri.
Fields
Uri
Bytes the provider fetches, named by URI.
Gemini takes any MIME type this way. OpenAI takes only images; anything else reaches the model as a line of text naming the file, because there is no field on that API to put it in.
Implementations§
Source§impl ContentPart
impl ContentPart
pub fn text(text: impl Into<String>) -> Self
pub fn blob(mime_type: impl Into<String>, data: Vec<u8>) -> Self
pub fn uri(mime_type: impl Into<String>, uri: impl Into<String>) -> Self
Trait Implementations§
Source§impl Clone for ContentPart
impl Clone for ContentPart
Source§impl Debug for ContentPart
See MessageContent’s Debug: the bytes are a count.
impl Debug for ContentPart
See MessageContent’s Debug: the bytes are a count.
Source§impl<'de> Deserialize<'de> for ContentPart
impl<'de> Deserialize<'de> for ContentPart
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ContentPart
Source§impl From<ContentPart> for MessageContent
impl From<ContentPart> for MessageContent
Source§fn from(part: ContentPart) -> Self
fn from(part: ContentPart) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ContentPart
impl PartialEq for ContentPart
Source§impl Serialize for ContentPart
impl Serialize 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
Mutably borrows from an owned value. Read more