#[non_exhaustive]pub enum TrackOrigin {
Embedded,
Sidecar,
External,
Derived,
Other(SmolStr),
}alloc or std only.Expand description
Where this subtitle track came from, relative to the media file it accompanies.
Open vocabulary: the named variants cover the buckets a media
pipeline sorts tracks into, and Self::Other carries a
classification this build does not name. mediaframe is a shared
library, not one pipeline’s private enum — the set of provenances
worth distinguishing belongs to whoever is doing the classifying,
so a downstream that tracks a distinction this crate has not heard
of keeps its name rather than losing it to a nearby variant.
Embedded is the default — the typical case is a subtitle stream
multiplexed inside the container. The named variants keep stable,
append-only u32 ids; Self::Other has none (see
Self::to_u32), so the slug from Self::as_str is the
spelling that always survives.
#[non_exhaustive] is retained: promoting a slug that rides
Other today into a named variant tomorrow stays a minor change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Embedded
Stream multiplexed into the container alongside the video /
audio tracks (e.g. an .mkv with embedded .srt-equivalent
subtitle streams). The default origin.
Sidecar
Separate subtitle file living next to the media file on disk
— typically an external .srt / .vtt / .ass paired with
the video by filename stem.
External
Externally sourced — downloaded from an online subtitle
database, or otherwise obtained ready-made from outside the
original media container. The track existed as subtitle text
before this pipeline saw the media; contrast Self::Derived,
which this pipeline produced from the media itself.
Derived
Produced by a processing pass over the media rather than obtained as subtitle text — an automatic-speech-recognition transcript, a machine translation of another track, OCR of image-based subtitles, or any comparable derivation.
The axis this variant adds is provenance-by-derivation: the
bytes have no existence independent of a pipeline stage, so
their quality, licensing and re-generability differ from a
track that arrived as text. Self::External covers the
arrived-as-text case even when the arrival was a download.
Other(SmolStr)
A provenance this vocabulary does not name — carried verbatim,
ASCII-folded to lowercase by the parse gate. The crate-wide
extension idiom: a downstream classifier naming an origin
mediaframe has never heard of keeps that name, and it
round-trips through as_str / FromStr / serde intact.
Implementations§
Source§impl TrackOrigin
impl TrackOrigin
Sourcepub const fn is_embedded(&self) -> bool
pub const fn is_embedded(&self) -> bool
Returns true if this value is of type Embedded. Returns false otherwise
Sourcepub const fn is_sidecar(&self) -> bool
pub const fn is_sidecar(&self) -> bool
Returns true if this value is of type Sidecar. Returns false otherwise
Sourcepub const fn is_external(&self) -> bool
pub const fn is_external(&self) -> bool
Returns true if this value is of type External. Returns false otherwise
Sourcepub const fn is_derived(&self) -> bool
pub const fn is_derived(&self) -> bool
Returns true if this value is of type Derived. Returns false otherwise
Source§impl TrackOrigin
impl TrackOrigin
Sourcepub fn unwrap_embedded(self)
pub fn unwrap_embedded(self)
Unwraps this value to the TrackOrigin::Embedded variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_embedded_ref(&self)
pub fn unwrap_embedded_ref(&self)
Unwraps this reference to the TrackOrigin::Embedded variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_embedded_mut(&mut self)
pub fn unwrap_embedded_mut(&mut self)
Unwraps this mutable reference to the TrackOrigin::Embedded variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_sidecar(self)
pub fn unwrap_sidecar(self)
Unwraps this value to the TrackOrigin::Sidecar variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_sidecar_ref(&self)
pub fn unwrap_sidecar_ref(&self)
Unwraps this reference to the TrackOrigin::Sidecar variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_sidecar_mut(&mut self)
pub fn unwrap_sidecar_mut(&mut self)
Unwraps this mutable reference to the TrackOrigin::Sidecar variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_external(self)
pub fn unwrap_external(self)
Unwraps this value to the TrackOrigin::External variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_external_ref(&self)
pub fn unwrap_external_ref(&self)
Unwraps this reference to the TrackOrigin::External variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_external_mut(&mut self)
pub fn unwrap_external_mut(&mut self)
Unwraps this mutable reference to the TrackOrigin::External variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_derived(self)
pub fn unwrap_derived(self)
Unwraps this value to the TrackOrigin::Derived variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_derived_ref(&self)
pub fn unwrap_derived_ref(&self)
Unwraps this reference to the TrackOrigin::Derived variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_derived_mut(&mut self)
pub fn unwrap_derived_mut(&mut self)
Unwraps this mutable reference to the TrackOrigin::Derived variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_other(self) -> SmolStr
pub fn unwrap_other(self) -> SmolStr
Unwraps this value to the TrackOrigin::Other variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_other_ref(&self) -> &SmolStr
pub fn unwrap_other_ref(&self) -> &SmolStr
Unwraps this reference to the TrackOrigin::Other variant.
Panics if this value is of any other type.
Sourcepub fn unwrap_other_mut(&mut self) -> &mut SmolStr
pub fn unwrap_other_mut(&mut self) -> &mut SmolStr
Unwraps this mutable reference to the TrackOrigin::Other variant.
Panics if this value is of any other type.
Source§impl TrackOrigin
impl TrackOrigin
Sourcepub fn try_unwrap_embedded(self) -> Result<(), TryUnwrapError<Self>>
pub fn try_unwrap_embedded(self) -> Result<(), TryUnwrapError<Self>>
Attempts to unwrap this value to the TrackOrigin::Embedded variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_embedded_ref(&self) -> Result<(), TryUnwrapError<&Self>>
pub fn try_unwrap_embedded_ref(&self) -> Result<(), TryUnwrapError<&Self>>
Attempts to unwrap this reference to the TrackOrigin::Embedded variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_embedded_mut(
&mut self,
) -> Result<(), TryUnwrapError<&mut Self>>
pub fn try_unwrap_embedded_mut( &mut self, ) -> Result<(), TryUnwrapError<&mut Self>>
Attempts to unwrap this mutable reference to the TrackOrigin::Embedded variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_sidecar(self) -> Result<(), TryUnwrapError<Self>>
pub fn try_unwrap_sidecar(self) -> Result<(), TryUnwrapError<Self>>
Attempts to unwrap this value to the TrackOrigin::Sidecar variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_sidecar_ref(&self) -> Result<(), TryUnwrapError<&Self>>
pub fn try_unwrap_sidecar_ref(&self) -> Result<(), TryUnwrapError<&Self>>
Attempts to unwrap this reference to the TrackOrigin::Sidecar variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_sidecar_mut(
&mut self,
) -> Result<(), TryUnwrapError<&mut Self>>
pub fn try_unwrap_sidecar_mut( &mut self, ) -> Result<(), TryUnwrapError<&mut Self>>
Attempts to unwrap this mutable reference to the TrackOrigin::Sidecar variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_external(self) -> Result<(), TryUnwrapError<Self>>
pub fn try_unwrap_external(self) -> Result<(), TryUnwrapError<Self>>
Attempts to unwrap this value to the TrackOrigin::External variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_external_ref(&self) -> Result<(), TryUnwrapError<&Self>>
pub fn try_unwrap_external_ref(&self) -> Result<(), TryUnwrapError<&Self>>
Attempts to unwrap this reference to the TrackOrigin::External variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_external_mut(
&mut self,
) -> Result<(), TryUnwrapError<&mut Self>>
pub fn try_unwrap_external_mut( &mut self, ) -> Result<(), TryUnwrapError<&mut Self>>
Attempts to unwrap this mutable reference to the TrackOrigin::External variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_derived(self) -> Result<(), TryUnwrapError<Self>>
pub fn try_unwrap_derived(self) -> Result<(), TryUnwrapError<Self>>
Attempts to unwrap this value to the TrackOrigin::Derived variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_derived_ref(&self) -> Result<(), TryUnwrapError<&Self>>
pub fn try_unwrap_derived_ref(&self) -> Result<(), TryUnwrapError<&Self>>
Attempts to unwrap this reference to the TrackOrigin::Derived variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_derived_mut(
&mut self,
) -> Result<(), TryUnwrapError<&mut Self>>
pub fn try_unwrap_derived_mut( &mut self, ) -> Result<(), TryUnwrapError<&mut Self>>
Attempts to unwrap this mutable reference to the TrackOrigin::Derived variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_other(self) -> Result<SmolStr, TryUnwrapError<Self>>
pub fn try_unwrap_other(self) -> Result<SmolStr, TryUnwrapError<Self>>
Attempts to unwrap this value to the TrackOrigin::Other variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_other_ref(&self) -> Result<&SmolStr, TryUnwrapError<&Self>>
pub fn try_unwrap_other_ref(&self) -> Result<&SmolStr, TryUnwrapError<&Self>>
Attempts to unwrap this reference to the TrackOrigin::Other variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Sourcepub fn try_unwrap_other_mut(
&mut self,
) -> Result<&mut SmolStr, TryUnwrapError<&mut Self>>
pub fn try_unwrap_other_mut( &mut self, ) -> Result<&mut SmolStr, TryUnwrapError<&mut Self>>
Attempts to unwrap this mutable reference to the TrackOrigin::Other variant.
Returns a [TryUnwrapError] with the original value if this value is of any other type.
Source§impl TrackOrigin
impl TrackOrigin
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Canonical lowercase slug for this origin ("embedded" /
"sidecar" / "external" / "derived"). Stable; matches what
core::fmt::Display produces. Self::Other returns the
wrapped slug verbatim.
Sourcepub const fn to_u32(&self) -> Option<u32>
pub const fn to_u32(&self) -> Option<u32>
Stable u32 wire id for the named origins: Embedded=0,
Sidecar=1, External=2, Derived=3. Append-only — never
renumber.
None for Self::Other: it names an origin this build has
no id for, and inventing one would lose the name. The slug from
Self::as_str is the spelling that always survives — which is
why the wire codecs (serde, buffa) carry the slug and not
this number.
Sourcepub const fn from_u32(v: u32) -> Self
pub const fn from_u32(v: u32) -> Self
Decodes from the stable u32 wire id produced by
Self::to_u32. Unknown ids fall back to the default
(Self::Embedded): the numeric space is this crate’s own and
an id it never assigned carries no name to preserve, so
Self::Other is not the right home for one. The round-trip is
exact for the enumerated ids 0/1/2/3.
Sourcepub const fn try_from_u32(v: u32) -> Option<Self>
pub const fn try_from_u32(v: u32) -> Option<Self>
Strict counterpart to Self::from_u32: returns None for any code
outside the enumerated set, instead of silently mapping it to the
default. Used by the strict deserialize path so adversarial / corrupt
wire values fail loudly rather than masquerading as Embedded.
Sourcepub fn other(slug: impl AsRef<str>) -> Self
pub fn other(slug: impl AsRef<str>) -> Self
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 TrackOrigin
impl TrackOrigin
Sourcepub const ROSTER: &'static [Self]
pub const ROSTER: &'static [Self]
Every track origin 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 TrackOrigin
impl Arbitrary for TrackOrigin
Source§impl<'a> Arbitrary<'a> for TrackOrigin
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for TrackOrigin
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 TrackOrigin
impl Clone for TrackOrigin
Source§fn clone(&self) -> TrackOrigin
fn clone(&self) -> TrackOrigin
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 TrackOrigin
impl Debug for TrackOrigin
Source§impl Default for TrackOrigin
impl Default for TrackOrigin
Source§fn default() -> TrackOrigin
fn default() -> TrackOrigin
Source§impl DefaultInstance for TrackOrigin
Available on crate feature buffa only.
impl DefaultInstance for TrackOrigin
buffa only.Source§fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Source§impl<'de> Deserialize<'de> for TrackOrigin
Available on crate feature serde only.
impl<'de> Deserialize<'de> for TrackOrigin
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 TrackOrigin
impl Display for TrackOrigin
impl Eq for TrackOrigin
Source§impl FromStr for TrackOrigin
impl FromStr for TrackOrigin
Source§type Err = !
type Err = !
Unconditionally Infallible — unlike
the all-tier vocabularies, this one needs no cfg split, because
the module itself exists only where the escape does. There is no
tier at which the parse can refuse, so there is nothing to fork.
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses the canonical slug Self::as_str renders — the exact
inverse of Display.
§Errors
Never, and the type says so: a slug this vocabulary does not name
rides Self::Other, ASCII-folded to lowercase by Self::other,
so Self::Err is uninhabited and a caller can discharge it with an
irrefutable let Ok(o) = s.parse::<TrackOrigin>();.
Source§impl Hash for TrackOrigin
impl Hash for TrackOrigin
Source§impl Message for TrackOrigin
Available on crate feature buffa only.
impl Message for TrackOrigin
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 TrackOrigin
impl PartialEq for TrackOrigin
Source§impl Serialize for TrackOrigin
Available on crate feature serde only.
impl Serialize for TrackOrigin
serde only.