Skip to main content

TrackOrigin

Enum TrackOrigin 

Source
#[non_exhaustive]
pub enum TrackOrigin { Embedded, Sidecar, External, Derived, Other(SmolStr), }
Available on crate features 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
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.
§

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

Source

pub const fn is_embedded(&self) -> bool

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

Source

pub const fn is_sidecar(&self) -> bool

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

Source

pub const fn is_external(&self) -> bool

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

Source

pub const fn is_derived(&self) -> bool

Returns true if this value is of type Derived. 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 TrackOrigin

Source

pub fn unwrap_embedded(self)

Unwraps this value to the TrackOrigin::Embedded variant. Panics if this value is of any other type.

Source

pub fn unwrap_embedded_ref(&self)

Unwraps this reference to the TrackOrigin::Embedded variant. Panics if this value is of any other type.

Source

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.

Source

pub fn unwrap_sidecar(self)

Unwraps this value to the TrackOrigin::Sidecar variant. Panics if this value is of any other type.

Source

pub fn unwrap_sidecar_ref(&self)

Unwraps this reference to the TrackOrigin::Sidecar variant. Panics if this value is of any other type.

Source

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.

Source

pub fn unwrap_external(self)

Unwraps this value to the TrackOrigin::External variant. Panics if this value is of any other type.

Source

pub fn unwrap_external_ref(&self)

Unwraps this reference to the TrackOrigin::External variant. Panics if this value is of any other type.

Source

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.

Source

pub fn unwrap_derived(self)

Unwraps this value to the TrackOrigin::Derived variant. Panics if this value is of any other type.

Source

pub fn unwrap_derived_ref(&self)

Unwraps this reference to the TrackOrigin::Derived variant. Panics if this value is of any other type.

Source

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.

Source

pub fn unwrap_other(self) -> SmolStr

Unwraps this value to the TrackOrigin::Other variant. Panics if this value is of any other type.

Source

pub fn unwrap_other_ref(&self) -> &SmolStr

Unwraps this reference to the TrackOrigin::Other variant. Panics if this value is of any other type.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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

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 TrackOrigin

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 TrackOrigin

Source§

fn clone(&self) -> TrackOrigin

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 TrackOrigin

Source§

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

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

impl Default for TrackOrigin

Source§

fn default() -> TrackOrigin

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

impl DefaultInstance for TrackOrigin

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 TrackOrigin

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 TrackOrigin

Source§

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

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

impl Eq for TrackOrigin

Source§

impl FromStr for TrackOrigin

Source§

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>

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

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 TrackOrigin

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 TrackOrigin

Source§

fn eq(&self, other: &TrackOrigin) -> 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 TrackOrigin

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 TrackOrigin

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 = !

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.