pub struct Attachment {
pub data: Vec<u8>,
pub media_type: String,
}Expand description
Image attachment for multi-modal messages.
Supports JPEG, PNG, GIF, and WebP. Data is stored as raw bytes and base64-encoded when serialized for LLM APIs.
Fields§
§data: Vec<u8>Raw image bytes
media_type: StringMIME type (e.g., "image/jpeg", "image/png")
Implementations§
Source§impl Attachment
impl Attachment
Sourcepub fn new(data: Vec<u8>, media_type: impl Into<String>) -> Self
pub fn new(data: Vec<u8>, media_type: impl Into<String>) -> Self
Create an attachment from raw bytes and media type.
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Read an image file and auto-detect media type from extension.
Sourcepub fn base64_data(&self) -> String
pub fn base64_data(&self) -> String
Return the base64-encoded data.
Sourcepub fn to_content_block(&self) -> ContentBlock
pub fn to_content_block(&self) -> ContentBlock
Convert to a ContentBlock::Image.
Trait Implementations§
Source§impl Clone for Attachment
impl Clone for Attachment
Source§fn clone(&self) -> Attachment
fn clone(&self) -> Attachment
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 moreAuto Trait Implementations§
impl Freeze for Attachment
impl RefUnwindSafe for Attachment
impl Send for Attachment
impl Sync for Attachment
impl Unpin for Attachment
impl UnsafeUnpin for Attachment
impl UnwindSafe for Attachment
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