Skip to main content

MasterPlaylist

Struct MasterPlaylist 

Source
pub struct MasterPlaylist {
    pub version: u8,
    pub variants: Vec<Variant>,
    pub iframe_variants: Vec<IFrameVariant>,
    pub extra_tags: Vec<String>,
    pub independent_segments: bool,
    pub start: Option<StartPoint>,
    pub defines: Vec<Define>,
    pub session_data: Vec<SessionData>,
    pub session_keys: Vec<SessionKey>,
    pub content_steering: Option<ContentSteering>,
}
Expand description

A master playlist (#EXTM3U / #EXT-X-STREAM-INF / …).

Fields§

§version: u8

#EXT-X-VERSION — an explicit floor, not the rendered value. 0 means “no explicit floor”: Self::to_m3u8 renders exactly Self::computed_version, or no tag at all when nothing triggers one. A nonzero value is raised — never lowered — to the computed minimum. See the module’s “Protocol version derivation” docs (issue #871).

§variants: Vec<Variant>

Ordered list of variant streams.

§iframe_variants: Vec<IFrameVariant>

Ordered list of I-frame-only renditions (RFC 8216 §4.3.4.2).

Each entry is rendered as an #EXT-X-I-FRAME-STREAM-INF line with the URI as an attribute (not a following line). An empty Vec (the default) produces no such lines.

§extra_tags: Vec<String>

Extra tag lines emitted verbatim after the variant/I-frame-variant entries (e.g. #EXT-X-MEDIA:...) — the Multivariant-Playlist counterpart of MediaPlaylist::extra_tags. Self::parse preserves any unrecognized #EXT-... tag here (forward-compat) instead of dropping it; Self::computed_version scans these lines for the §8 rows this crate does not model as typed struct fields (rows 7/12/13 — docs/version-compatibility.md). Rows 8 and 11 were also scanned here until issue #872 gave EXT-X-DEFINE a typed representation; they now read Self::defines instead.

§independent_segments: bool

#EXT-X-INDEPENDENT-SEGMENTS (RFC 8216bis §4.4.2.1, issue #872).

§start: Option<StartPoint>

#EXT-X-START (RFC 8216bis §4.4.2.2, issue #872).

§defines: Vec<Define>

#EXT-X-DEFINE entries (RFC 8216bis §4.4.2.3, issue #872), in wire order. Feeds §8 row 11 via Self::computed_version.

§session_data: Vec<SessionData>

#EXT-X-SESSION-DATA entries (RFC 8216bis §4.4.6.4, issue #872), in wire order.

§session_keys: Vec<SessionKey>

#EXT-X-SESSION-KEY entries (RFC 8216bis §4.4.6.5, issue #872), in wire order.

§content_steering: Option<ContentSteering>

#EXT-X-CONTENT-STEERING (RFC 8216bis §4.4.6.6, issue #872) — at most one per Playlist.

Implementations§

Source§

impl MasterPlaylist

Source

pub fn to_m3u8(&self) -> String

Render this master playlist as an RFC 8216 #EXTM3U string.

After the regular #EXT-X-STREAM-INF variant lines, emits one #EXT-X-I-FRAME-STREAM-INF line per entry in Self::iframe_variants (RFC 8216 §4.3.4.2). The URI is rendered as an attribute on the tag line itself — not on a following line.

Source

pub fn parse(input: &str) -> Result<Self>

Parse an RFC 8216 #EXTM3U Multivariant (Master) Playlist — the symmetric inverse of Self::to_m3u8.

Recognizes #EXT-X-VERSION, #EXT-X-STREAM-INF + its following URI line, and #EXT-X-I-FRAME-STREAM-INF. #EXT-X-MEDIA (alternate audio/subtitle renditions), #EXT-X-DEFINE, and any other unrecognized #EXT-... tag are not modeled with typed fields, but are preserved verbatim into Self::extra_tags (forward-compat), mirroring MediaPlaylist::parse. A malformed #EXT-X-STREAM-INF/#EXT-X-I-FRAME-STREAM-INF (missing required attribute, unparsable value) or a variant URI with no preceding #EXT-X-STREAM-INF returns crate::Error::HlsParse.

Source

pub fn computed_version(&self) -> Option<u8>

Compute the minimum #EXT-X-VERSION this Multivariant Playlist’s actual content requires, per RFC 8216bis §8 (docs/version-compatibility.md). None means fully compatible with version 1 (no tag required). See MediaPlaylist::computed_version for the Media-Playlist-only rows (2–6, 9–10) that do not apply to a Multivariant Playlist.

Trait Implementations§

Source§

impl Clone for MasterPlaylist

Source§

fn clone(&self) -> MasterPlaylist

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 MasterPlaylist

Source§

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

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

impl Default for MasterPlaylist

Source§

fn default() -> MasterPlaylist

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

impl PartialEq for MasterPlaylist

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MasterPlaylist

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<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> 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> 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, 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.