#[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
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)
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
impl DynamicRange
Sourcepub const fn is_unspecified(&self) -> bool
pub const fn is_unspecified(&self) -> bool
Returns true if this value is of type Unspecified. Returns false otherwise
Sourcepub const fn is_limited(&self) -> bool
pub const fn is_limited(&self) -> bool
Returns true if this value is of type Limited. Returns false otherwise
Source§impl DynamicRange
impl DynamicRange
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Lowercase FFmpeg-style identifier for this variant
(AVCOL_RANGE_* slug; tv / pc).
Sourcepub const fn to_u32(&self) -> Option<u32>
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.
Sourcepub const fn from_u32(v: u32) -> Option<Self>
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.
Sourcepub fn other(slug: impl AsRef<str>) -> Self
Available on crate features alloc or std only.
pub fn other(slug: impl AsRef<str>) -> Self
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
impl DynamicRange
Sourcepub const ROSTER: &'static [Self]
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.
impl Arbitrary for DynamicRange
quickcheck only.Source§impl<'a> Arbitrary<'a> for DynamicRange
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for DynamicRange
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Clone for DynamicRange
impl Clone for DynamicRange
Source§fn clone(&self) -> DynamicRange
fn clone(&self) -> DynamicRange
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 DynamicRange
impl Debug for DynamicRange
Source§impl Default for DynamicRange
impl Default for DynamicRange
Source§impl DefaultInstance for DynamicRange
Available on crate feature buffa only.
impl DefaultInstance for DynamicRange
buffa only.Source§fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Source§impl<'de> Deserialize<'de> for DynamicRange
Available on crate feature serde only.
impl<'de> Deserialize<'de> for DynamicRange
serde only.Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Source§impl Display for DynamicRange
impl Display for DynamicRange
impl Eq for DynamicRange
Source§impl FromStr for DynamicRange
impl FromStr for DynamicRange
Source§type Err = Infallible
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>
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
impl Hash for DynamicRange
Source§impl Message for DynamicRange
Available on crate feature buffa only.
impl Message for DynamicRange
buffa only.Source§fn compute_size(&self, _cache: &mut SizeCache) -> u32
fn compute_size(&self, _cache: &mut SizeCache) -> u32
cache for write_to to consume. Read moreSource§fn write_to(&self, _cache: &mut SizeCache, buf: &mut impl EncodeSink)
fn write_to(&self, _cache: &mut SizeCache, buf: &mut impl EncodeSink)
cache (populated by a prior
compute_size call on the same cache). Read moreSource§fn merge_field(
&mut self,
tag: Tag,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
) -> Result<(), DecodeError>
fn merge_field( &mut self, tag: Tag, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>
buf. Read moreSource§fn encode(&self, buf: &mut impl EncodeSink)
fn encode(&self, buf: &mut impl EncodeSink)
Source§fn try_encode(&self, buf: &mut impl EncodeSink) -> Result<(), EncodeError>
fn try_encode(&self, buf: &mut impl EncodeSink) -> Result<(), EncodeError>
MAX_MESSAGE_BYTES). Read moreSource§fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)
fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)
Source§fn try_encode_with_cache(
&self,
cache: &mut SizeCache,
buf: &mut impl EncodeSink,
) -> Result<(), EncodeError>
fn try_encode_with_cache( &self, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>
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 moreSource§fn try_encode_bounded(
&self,
max_bytes: u32,
buf: &mut impl EncodeSink,
) -> Result<u32, EncodeError>
fn try_encode_bounded( &self, max_bytes: u32, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>
buf only if its encoded size fits within
max_bytes, using a single size pass that is then reused for the write. Read moreSource§fn try_encode_bounded_with_cache(
&self,
max_bytes: u32,
cache: &mut SizeCache,
buf: &mut impl EncodeSink,
) -> Result<u32, EncodeError>
fn try_encode_bounded_with_cache( &self, max_bytes: u32, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>
Source§fn encoded_len(&self) -> u32
fn encoded_len(&self) -> u32
Source§fn try_encoded_len(&self) -> Result<u32, EncodeError>
fn try_encoded_len(&self) -> Result<u32, EncodeError>
MAX_MESSAGE_BYTES). Read moreSource§fn encode_length_delimited(&self, buf: &mut impl EncodeSink)
fn encode_length_delimited(&self, buf: &mut impl EncodeSink)
Source§fn try_encode_length_delimited(
&self,
buf: &mut impl EncodeSink,
) -> Result<(), EncodeError>
fn try_encode_length_delimited( &self, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>
MAX_MESSAGE_BYTES). Read moreSource§fn try_encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>
fn try_encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>
Vec<u8>, returning an error instead of panicking
if the encoded size exceeds the 2 GiB protobuf limit
(MAX_MESSAGE_BYTES). Read moreSource§fn encode_to_bytes(&self) -> Bytes
fn encode_to_bytes(&self) -> Bytes
bytes::Bytes. Read moreSource§fn try_encode_to_bytes(&self) -> Result<Bytes, EncodeError>
fn try_encode_to_bytes(&self) -> Result<Bytes, EncodeError>
bytes::Bytes, returning an error instead of
panicking if the encoded size exceeds the 2 GiB protobuf limit
(MAX_MESSAGE_BYTES). Read moreSource§fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn merge_to_limit(
&mut self,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
limit: usize,
) -> Result<(), DecodeError>
fn merge_to_limit( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, limit: usize, ) -> Result<(), DecodeError>
Source§fn merge_group(
&mut self,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
field_number: u32,
) -> Result<(), DecodeError>
fn merge_group( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, field_number: u32, ) -> Result<(), DecodeError>
buf, reading fields until an
EndGroup tag with the given field_number is encountered. Read moreSource§fn merge(
&mut self,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
) -> Result<(), DecodeError>
fn merge( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>
Source§fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
Source§fn merge_length_delimited(
&mut self,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
) -> Result<(), DecodeError>
fn merge_length_delimited( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>
Source§impl PartialEq for DynamicRange
impl PartialEq for DynamicRange
Source§impl Serialize for DynamicRange
Available on crate feature serde only.
impl Serialize for DynamicRange
serde only.