Skip to main content

DynamicRange

Enum DynamicRange 

Source
#[non_exhaustive]
pub enum DynamicRange { Unspecified, Limited, Full, Other(SmolStr), }
Expand description

Sample range — limited (TV / studio swing) vs. full (PC).

Self::to_u32 / Self::from_u32 use the FFmpeg AVColorRange code points (UNSPECIFIED=0, MPEG=1, JPEG=2); FFmpeg is the source of truth. Default is Self::Unspecified (FFmpeg AVCOL_RANGE_UNSPECIFIED, code 0); Self::Other carries any name this build does not enumerate, so the text round-trip is lossless.

Tier. Self::Other needs a heap, so it exists only at the alloc / std tier; at the no-alloc tier this vocabulary is closed and an unrecognised slug is rejected rather than collapsed onto a named variant — an error beats a wrong value.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Unspecified

Unspecified — caller assumes Limited.

§

Limited

Limited / studio swing (8-bit luma 16..235, chroma 16..240); FFmpeg AVCOL_RANGE_MPEG.

§

Full

Full / PC swing (8-bit 0..255); FFmpeg AVCOL_RANGE_JPEG.

§

Other(SmolStr)

Available on crate features alloc or std only.

A slug this vocabulary does not enumerate — carried verbatim, ASCII-folded to lowercase by the parse gate. The crate-wide extension idiom: a downstream backend naming a value mediaframe has never heard of keeps that name, and it round-trips through as_str / FromStr / serde intact.

Requires the alloc feature (std includes it) — the payload is heap-capable. At the no-alloc tier the vocabulary is closed and an unrecognised slug is rejected instead.

Implementations§

Source§

impl DynamicRange

Source

pub const fn is_unspecified(&self) -> bool

Returns true if this value is of type Unspecified. Returns false otherwise

Source

pub const fn is_limited(&self) -> bool

Returns true if this value is of type Limited. Returns false otherwise

Source

pub const fn is_full(&self) -> bool

Returns true if this value is of type Full. Returns false otherwise

Source

pub const fn is_other(&self) -> bool

Returns true if this value is of type Other. Returns false otherwise

Source§

impl DynamicRange

Source

pub fn as_str(&self) -> &str

Lowercase FFmpeg-style identifier for this variant (AVCOL_RANGE_* slug; tv / pc).

Source

pub const fn to_u32(&self) -> Option<u32>

The FFmpeg AVColorRange code point.

None for Self::Other: it names something FFmpeg has no code for, and inventing one would lose the name.

Source

pub const fn from_u32(v: u32) -> Option<Self>

Decodes from the FFmpeg AVColorRange code produced by Self::to_u32.

None for a code this build names nothing for — a number is FFmpeg’s spelling, not a name to preserve.

Source

pub fn other(slug: impl AsRef<str>) -> Self

Available on crate features alloc or std only.

The open escape for a slug this vocabulary does not name, ASCII-folded to the crate’s lowercase canon.

The one construction path for Self::Other: folding here is what keeps the whole value space lowercase-canonical, so the derived Eq / Hash compare names rather than spellings. Constructing the variant directly bypasses the fold and is not the supported spelling.

Source§

impl DynamicRange

Source

pub const ROSTER: &'static [Self]

Every dynamic range this vocabulary names, in declaration order.

A slice rather than an array: how many names this build carries is a fact about the release, not part of the type, so a later addition stays a minor change.

The open escape arm is not a member. The roster answers “which names does this build know”, and the escape is precisely the arm that carries a name it does not — listing it would need a slug to put in it, and there isn’t one.

Trait Implementations§

Source§

impl Arbitrary for DynamicRange

Available on crate feature quickcheck only.
Source§

fn arbitrary(__quickcheck_g: &mut Gen) -> Self

Return an arbitrary value. Read more
Source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
Source§

impl<'a> Arbitrary<'a> for DynamicRange

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for DynamicRange

Source§

fn clone(&self) -> DynamicRange

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DynamicRange

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DynamicRange

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DefaultInstance for DynamicRange

Available on crate feature buffa only.
Source§

fn default_instance() -> &'static Self

Return a reference to the single default instance of this type.
Source§

impl<'de> Deserialize<'de> for DynamicRange

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for DynamicRange

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DynamicRange

Source§

impl FromStr for DynamicRange

Source§

type Err = Infallible

Infallible wherever the escape arm exists, which is exactly where the parse is total; the vocabulary’s own refusal at the no-alloc tier, where it is closed. The predicate is the one that gates Self::Other, so the two cannot drift.

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Reads a sample-range name: the canonical slug Self::as_str renders, or FFmpeg’s spelling of the same code point where the two differ.

Emission is injective and canonical — never a synonym — so parse(display(x)) == x holds for every named variant. Parse also takes av_color_range_name’s unknown (Self::Unspecified); tv and pc are already FFmpeg’s own spellings.

§Errors

Returns ParseDynamicRangeError only at the no-alloc tier, where the vocabulary is closed. At the alloc / std tier this parse is total — a slug this type does not name rides Self::Other, ASCII-folded to lowercase by Self::other — and Self::Err is Infallible there, so the totality is checkable by the compiler rather than only promised here.

Source§

impl Hash for DynamicRange

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for DynamicRange

Available on crate feature buffa only.
Source§

fn compute_size(&self, _cache: &mut SizeCache) -> u32

Compute the encoded byte size of this message, recording nested sub-message sizes in cache for write_to to consume. Read more
Source§

fn write_to(&self, _cache: &mut SizeCache, buf: &mut impl EncodeSink)

Write this message’s encoded bytes to a buffer, consuming nested-message sizes from cache (populated by a prior compute_size call on the same cache). Read more
Source§

fn merge_field( &mut self, tag: Tag, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>

Processes a single already-decoded tag and its associated field data from buf. Read more
Source§

fn clear(&mut self)

Clear all fields to their default values.
Source§

fn encode(&self, buf: &mut impl EncodeSink)

Compute size, then write. This is the primary encoding API. Read more
Source§

fn try_encode(&self, buf: &mut impl EncodeSink) -> Result<(), EncodeError>

Encode, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)

Encode using a caller-supplied SizeCache, for reuse across many encodes in a hot loop. Clears the cache first. Read more
Source§

fn try_encode_with_cache( &self, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>

Encode with a caller-supplied SizeCache, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Clears the cache first. Read more
Source§

fn try_encode_bounded( &self, max_bytes: u32, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>

Encode this message into buf only if its encoded size fits within max_bytes, using a single size pass that is then reused for the write. Read more
Source§

fn try_encode_bounded_with_cache( &self, max_bytes: u32, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>

Like try_encode_bounded but reuses an existing SizeCache, clearing it first. Read more
Source§

fn encoded_len(&self) -> u32

Compute the encoded byte size of this message. Read more
Source§

fn try_encoded_len(&self) -> Result<u32, EncodeError>

Compute the encoded byte size, returning an error instead of panicking if it exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_length_delimited(&self, buf: &mut impl EncodeSink)

Encode this message as a length-delimited byte sequence. Read more
Source§

fn try_encode_length_delimited( &self, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>

Encode as a length-delimited byte sequence, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>

Encode this message to a new Vec<u8>. Read more
Source§

fn try_encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>

Encode to a new Vec<u8>, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_to_bytes(&self) -> Bytes

Encode this message to a new bytes::Bytes. Read more
Source§

fn try_encode_to_bytes(&self) -> Result<Bytes, EncodeError>

Encode to a new bytes::Bytes, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>
where Self: Sized,

Decode a message from a buffer.
Source§

fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>
where Self: Sized,

Decode a message from a byte slice. Read more
Source§

fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>
where Self: Sized,

Decode a length-delimited message from a buffer. Read more
Source§

fn merge_to_limit( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, limit: usize, ) -> Result<(), DecodeError>

Merge fields from a buffer until buf.remaining() reaches limit. Read more
Source§

fn merge_group( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, field_number: u32, ) -> Result<(), DecodeError>

Merges a group-encoded message from buf, reading fields until an EndGroup tag with the given field_number is encountered. Read more
Source§

fn merge( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>

Merge fields from a buffer into this message. Read more
Source§

fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>

Merge fields from a byte slice into this message. Read more
Source§

fn merge_length_delimited( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>

Merge fields from a length-delimited sub-message payload into this message. Read more
Source§

impl PartialEq for DynamicRange

Source§

fn eq(&self, other: &DynamicRange) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for DynamicRange

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, ser: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DynamicRange

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.