pub enum MediaSource {
Url {
url: HttpsUrl,
},
InlineBytes {
mime: MediaType,
data: Vec<u8>,
},
ProviderFile {
file_id: ProviderFileId,
},
S3 {
uri: S3Uri,
bucket_owner: Option<AwsAccountId>,
},
}Expand description
Where the bytes of one media content part come from.
The four variants exhaust the source kinds supported by any backend
we care about: HTTPS URL (OpenAI, Anthropic), inline base64 (all),
provider-issued file id (OpenAI, Anthropic), and S3 URI (Bedrock).
Provider impls translate the source variant they natively speak and
return CapabilityError::SourceKindUnsupported for the rest — the
validation lives on the provider’s capability table, not here.
The serde representation is internally tagged on source:
{"source": "url", "url": "https://example.com/cat.png"}
{"source": "inline_bytes", "mime": "image/png", "data": "<base64>"}
{"source": "provider_file", "file_id": "file-..."}
{"source": "s3", "uri": "s3://bucket/key", "bucket_owner": "123456789012"}This in-crate JSON shape is intentionally provider-neutral. Downstream applications can map their own accepted input envelopes into these variants before sending a request.
Variants§
Url
A reachable HTTPS URL.
InlineBytes
Bytes carried inline. Serialized as base64 over JSON.
Fields
ProviderFile
A reference to bytes already uploaded to the provider’s Files API.
Fields
file_id: ProviderFileIdThe provider-issued file identifier.
S3
An S3 URI, with an optional explicit cross-account bucket owner.
Fields
bucket_owner: Option<AwsAccountId>12-digit account id of the bucket owner. Required for cross-account access; omit when the caller’s account owns the bucket.
Implementations§
Source§impl MediaSource
impl MediaSource
Sourcepub const fn kind(&self) -> SourceKind
pub const fn kind(&self) -> SourceKind
Return the discriminant of this source variant.
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>,
impl Eq for MediaSource
Source§impl PartialEq for MediaSource
impl PartialEq for MediaSource
Source§impl Serialize for MediaSource
impl Serialize 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more