pub enum UserContentBlock {
Text {
text: String,
},
Image {
source: ImageSource,
},
}Expand description
Content block for user prompts (input)
Represents content that can be included in user messages.
Variants§
Implementations§
Source§impl UserContentBlock
impl UserContentBlock
Sourcepub fn image_base64(
media_type: impl Into<String>,
data: impl Into<String>,
) -> Result<Self>
pub fn image_base64( media_type: impl Into<String>, data: impl Into<String>, ) -> Result<Self>
Create an image content block from base64 data
§Arguments
media_type- MIME type of the image (e.g., “image/png”, “image/jpeg”)data- Base64-encoded image data (without data URI prefix)
§Errors
Returns an error if:
- The MIME type is not supported (valid types: image/jpeg, image/png, image/gif, image/webp)
- The base64 data exceeds the maximum size limit (15MB)
§Example
let block = UserContentBlock::image_base64("image/png", "iVBORw0KGgo=")?;Sourcepub fn validate_content(blocks: &[UserContentBlock]) -> Result<()>
pub fn validate_content(blocks: &[UserContentBlock]) -> Result<()>
Validate a collection of content blocks
Ensures the content is non-empty. This is used internally by query functions to provide consistent validation.
§Errors
Returns an error if the content blocks slice is empty.
Trait Implementations§
Source§impl Clone for UserContentBlock
impl Clone for UserContentBlock
Source§fn clone(&self) -> UserContentBlock
fn clone(&self) -> UserContentBlock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UserContentBlock
impl Debug for UserContentBlock
Source§impl<'de> Deserialize<'de> for UserContentBlock
impl<'de> Deserialize<'de> for UserContentBlock
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
Source§impl From<&str> for UserContentBlock
impl From<&str> for UserContentBlock
Source§impl From<String> for UserContentBlock
impl From<String> for UserContentBlock
Source§impl PartialEq for UserContentBlock
impl PartialEq for UserContentBlock
Source§impl Serialize for UserContentBlock
impl Serialize for UserContentBlock
impl StructuralPartialEq for UserContentBlock
Auto Trait Implementations§
impl Freeze for UserContentBlock
impl RefUnwindSafe for UserContentBlock
impl Send for UserContentBlock
impl Sync for UserContentBlock
impl Unpin for UserContentBlock
impl UnwindSafe for UserContentBlock
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