hls-runtime 0.10.0

Sans-IO Low-Latency HLS (RFC 8216bis) client + server engines in one crate (blocking reload, part prefetch, rolling-window origin), with an optional tokio+reqwest IO adapter.
Documentation
//! Distinct integer types for the origin's resource-naming arguments
//! (issue #1159).
//!
//! `init_name(track, generation)`, `segment_name(track, seq, ext)` and
//! `part_name(track, seq, idx, ext)` used to take bare, adjacent `u32`s, so a
//! swapped argument still compiled and produced a plausible-looking but wrong
//! URL. Each of these is its own newtype, so a swap is a compile error. `SegmentSeq`/`PartIndex` are defined once in `media_plane::ids` (#1188) and re-exported here.
//!
//! `Display` and `Debug` render the bare number: they feed the wire names
//! (`seg-1-5-7.m4s`, `init-1-5-2.mp4`), which must not change.

use core::fmt;

macro_rules! id_newtype {
    ($(#[$meta:meta])* $name:ident) => {
        $(#[$meta])*
        #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
        pub struct $name(u32);

        impl $name {
            /// Wrap a raw value.
            #[must_use]
            pub const fn new(value: u32) -> Self {
                Self(value)
            }

            /// The raw value.
            #[must_use]
            pub const fn value(self) -> u32 {
                self.0
            }
        }

        impl fmt::Debug for $name {
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                fmt::Debug::fmt(&self.0, f)
            }
        }

        impl fmt::Display for $name {
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                fmt::Display::fmt(&self.0, f)
            }
        }
    };
}

id_newtype! {
    /// An init-segment generation: the version counter in
    /// `init-{track}-{instance}-{generation}.mp4`, starting at `1`.
    Generation
}