pub struct ImageAttachment {
pub mime: String,
pub data: String,
pub filename: Option<String>,
}Expand description
An image attached to a ChatML message (multimodal sidecar).
Stored out-of-band from content (which stays a plain String) so that
every existing text-only call site, checkpoint, and serialized transcript
keeps working unchanged. The field serializes only when non-empty and
deserializes to an empty vec when absent, so old JSON is accepted as-is.
Fields§
§mime: StringMIME type of the image (e.g., “image/jpeg”, “image/png”).
data: StringBase64-encoded image data (no data-URL prefix).
filename: Option<String>Original file name, when known (for display and error messages).
Implementations§
Source§impl ImageAttachment
impl ImageAttachment
Sourcepub fn new(mime: impl Into<String>, data: impl Into<String>) -> Self
pub fn new(mime: impl Into<String>, data: impl Into<String>) -> Self
Create an image attachment from a MIME type and base64 data.
Sourcepub fn with_filename(self, filename: impl Into<String>) -> Self
pub fn with_filename(self, filename: impl Into<String>) -> Self
Attach an original filename (builder style).
Sourcepub fn to_data_url(&self) -> String
pub fn to_data_url(&self) -> String
Render as a data URL (data:{mime};base64,{data}), the form used by
OpenAI-compatible image_url content parts.
Trait Implementations§
Source§impl Clone for ImageAttachment
impl Clone for ImageAttachment
Source§fn clone(&self) -> ImageAttachment
fn clone(&self) -> ImageAttachment
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ImageAttachment
impl Debug for ImageAttachment
Source§impl<'de> Deserialize<'de> for ImageAttachment
impl<'de> Deserialize<'de> for ImageAttachment
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 PartialEq for ImageAttachment
impl PartialEq for ImageAttachment
Source§impl Serialize for ImageAttachment
impl Serialize for ImageAttachment
impl StructuralPartialEq for ImageAttachment
Auto Trait Implementations§
impl Freeze for ImageAttachment
impl RefUnwindSafe for ImageAttachment
impl Send for ImageAttachment
impl Sync for ImageAttachment
impl Unpin for ImageAttachment
impl UnsafeUnpin for ImageAttachment
impl UnwindSafe for ImageAttachment
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