pub struct MediaSupport {
pub sources: EnumSet<SourceKind>,
pub formats: &'static [&'static str],
pub max_bytes: Option<u64>,
pub max_count_per_message: Option<u8>,
}Expand description
What a model accepts for one MediaKind.
Stored on ModelCapabilities::media_support keyed by MediaKind.
A missing entry (vs. an empty MediaSupport) means “not supported”;
an entry with empty sources is a bug in the table.
Fields§
§sources: EnumSet<SourceKind>Source kinds the provider can carry to this model for this
modality (e.g. Bedrock Image = {InlineBytes, S3}, no Url).
formats: &'static [&'static str]Accepted RFC-6838 subtypes (e.g. ["png", "jpeg", "gif", "webp"]).
Matched against MediaType::subtype.
Empty means “the provider didn’t publish a constraint; accept
any subtype” — use sparingly.
max_bytes: Option<u64>Max byte size accepted for MediaSource::InlineBytes. None
= no local check (e.g. for Url/ProviderFile/S3 sources the
size is opaque locally).
max_count_per_message: Option<u8>Max number of parts of this kind per message. None = no
declared limit; counts are still cheap to enforce locally.
Implementations§
Source§impl MediaSupport
impl MediaSupport
Sourcepub fn validate(
&self,
model: &str,
kind: MediaKind,
source: &MediaSource,
) -> Result<(), CapabilityError>
pub fn validate( &self, model: &str, kind: MediaKind, source: &MediaSource, ) -> Result<(), CapabilityError>
Validate one media source against this support entry.
URL, ProviderFile, and S3 sources skip format/size checks
— the bytes aren’t reachable locally and the provider performs
the equivalent check server-side. InlineBytes validates
mime.subtype() against Self::formats and data.len() against
Self::max_bytes.
§Errors
Returns the first matching CapabilityError variant.
Trait Implementations§
Source§impl Clone for MediaSupport
impl Clone for MediaSupport
Source§fn clone(&self) -> MediaSupport
fn clone(&self) -> MediaSupport
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 MediaSupport
impl Debug for MediaSupport
impl Eq for MediaSupport
Source§impl PartialEq for MediaSupport
impl PartialEq for MediaSupport
impl StructuralPartialEq for MediaSupport
Auto Trait Implementations§
impl Freeze for MediaSupport
impl RefUnwindSafe for MediaSupport
impl Send for MediaSupport
impl Sync for MediaSupport
impl Unpin for MediaSupport
impl UnsafeUnpin for MediaSupport
impl UnwindSafe for MediaSupport
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.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