#[non_exhaustive]pub enum MediaSource {
Url {
url: String,
media_type: Option<String>,
},
Base64 {
media_type: String,
data: String,
},
FileId {
id: String,
media_type: Option<String>,
},
}Expand description
How a media payload is delivered to the model.
Every codec routes on the variant alone, so adding a new modality
(ContentPart::Audio,
ContentPart::Video etc.) reuses the
same source shape — no parallel *Source enums.
media_type is required on MediaSource::Base64 (no other context
to infer from) and optional on MediaSource::Url /
MediaSource::FileId where URL extension or vendor metadata
typically supplies it.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Url
Hosted at an https:// URL the vendor can fetch directly.
Fields
Base64
Inlined as base64 bytes with a media type tag.
FileId
Already uploaded via the vendor’s Files API.
Covers OpenAI Files (file-… IDs), Gemini File API (files/… IDs),
Anthropic file inputs.
Implementations§
Source§impl MediaSource
impl MediaSource
Sourcepub fn base64(media_type: impl Into<String>, data: impl Into<String>) -> Self
pub fn base64(media_type: impl Into<String>, data: impl Into<String>) -> Self
Convenience constructor for a base64-inlined source.
Sourcepub fn file_id(id: impl Into<String>) -> Self
pub fn file_id(id: impl Into<String>) -> Self
Convenience constructor for a vendor file-id source.
Sourcepub fn media_type(&self) -> Option<&str>
pub fn media_type(&self) -> Option<&str>
Borrow the media type if known.
Trait Implementations§
Source§impl Clone for MediaSource
impl Clone for MediaSource
Source§fn clone(&self) -> MediaSource
fn clone(&self) -> MediaSource
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 MediaSource
impl Debug for MediaSource
Source§impl<'de> Deserialize<'de> for MediaSource
impl<'de> Deserialize<'de> for MediaSource
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>,
Source§impl PartialEq for MediaSource
impl PartialEq for MediaSource
Source§fn eq(&self, other: &MediaSource) -> bool
fn eq(&self, other: &MediaSource) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MediaSource
impl Serialize for MediaSource
impl Eq for MediaSource
impl StructuralPartialEq for MediaSource
Auto Trait Implementations§
impl Freeze for MediaSource
impl RefUnwindSafe for MediaSource
impl Send for MediaSource
impl Sync for MediaSource
impl Unpin for MediaSource
impl UnsafeUnpin for MediaSource
impl UnwindSafe for MediaSource
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.