mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-11-22 07:10:59 +00:00
fixed clippy warnings
This commit is contained in:
parent
1966a7608d
commit
cf97a45f60
30 changed files with 127 additions and 87 deletions
|
@ -9,6 +9,7 @@ readme = "README.md"
|
|||
license = "MIT"
|
||||
keywords = ["hls", "m3u8"]
|
||||
edition = "2018"
|
||||
categories = ["parser"]
|
||||
|
||||
[badges]
|
||||
travis-ci = {repository = "sile/hls_m3u8"}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
#![warn(
|
||||
//clippy::pedantic,
|
||||
clippy::nursery,
|
||||
clippy::cargo
|
||||
)]
|
||||
//! [HLS] m3u8 parser/generator.
|
||||
//!
|
||||
//! [HLS]: https://tools.ietf.org/html/rfc8216
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct Lines<'a> {
|
|||
input: &'a str,
|
||||
}
|
||||
impl<'a> Lines<'a> {
|
||||
pub fn new(input: &'a str) -> Self {
|
||||
pub const fn new(input: &'a str) -> Self {
|
||||
Lines { input }
|
||||
}
|
||||
|
||||
|
|
|
@ -238,17 +238,17 @@ pub struct MasterPlaylist {
|
|||
|
||||
impl MasterPlaylist {
|
||||
/// Returns the `EXT-X-VERSION` tag contained in the playlist.
|
||||
pub fn version_tag(&self) -> ExtXVersion {
|
||||
pub const fn version_tag(&self) -> ExtXVersion {
|
||||
self.version_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-INDEPENDENT-SEGMENTS` tag contained in the playlist.
|
||||
pub fn independent_segments_tag(&self) -> Option<ExtXIndependentSegments> {
|
||||
pub const fn independent_segments_tag(&self) -> Option<ExtXIndependentSegments> {
|
||||
self.independent_segments_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-START` tag contained in the playlist.
|
||||
pub fn start_tag(&self) -> Option<ExtXStart> {
|
||||
pub const fn start_tag(&self) -> Option<ExtXStart> {
|
||||
self.start_tag
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ pub struct MediaPlaylistBuilder {
|
|||
segments: Vec<MediaSegment>,
|
||||
options: MediaPlaylistOptions,
|
||||
}
|
||||
|
||||
impl MediaPlaylistBuilder {
|
||||
/// Makes a new `MediaPlaylistBuilder` instance.
|
||||
pub fn new() -> Self {
|
||||
|
@ -180,6 +181,7 @@ impl MediaPlaylistBuilder {
|
|||
.unwrap_or(ProtocolVersion::V1)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MediaPlaylistBuilder {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
|
@ -200,49 +202,50 @@ pub struct MediaPlaylist {
|
|||
end_list_tag: Option<ExtXEndList>,
|
||||
segments: Vec<MediaSegment>,
|
||||
}
|
||||
|
||||
impl MediaPlaylist {
|
||||
/// Returns the `EXT-X-VERSION` tag contained in the playlist.
|
||||
pub fn version_tag(&self) -> ExtXVersion {
|
||||
pub const fn version_tag(&self) -> ExtXVersion {
|
||||
self.version_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-TARGETDURATION` tag contained in the playlist.
|
||||
pub fn target_duration_tag(&self) -> ExtXTargetDuration {
|
||||
pub const fn target_duration_tag(&self) -> ExtXTargetDuration {
|
||||
self.target_duration_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-MEDIA-SEQUENCE` tag contained in the playlist.
|
||||
pub fn media_sequence_tag(&self) -> Option<ExtXMediaSequence> {
|
||||
pub const fn media_sequence_tag(&self) -> Option<ExtXMediaSequence> {
|
||||
self.media_sequence_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-DISCONTINUITY-SEQUENCE` tag contained in the playlist.
|
||||
pub fn discontinuity_sequence_tag(&self) -> Option<ExtXDiscontinuitySequence> {
|
||||
pub const fn discontinuity_sequence_tag(&self) -> Option<ExtXDiscontinuitySequence> {
|
||||
self.discontinuity_sequence_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-PLAYLIST-TYPE` tag contained in the playlist.
|
||||
pub fn playlist_type_tag(&self) -> Option<ExtXPlaylistType> {
|
||||
pub const fn playlist_type_tag(&self) -> Option<ExtXPlaylistType> {
|
||||
self.playlist_type_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-I-FRAMES-ONLY` tag contained in the playlist.
|
||||
pub fn i_frames_only_tag(&self) -> Option<ExtXIFramesOnly> {
|
||||
pub const fn i_frames_only_tag(&self) -> Option<ExtXIFramesOnly> {
|
||||
self.i_frames_only_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-INDEPENDENT-SEGMENTS` tag contained in the playlist.
|
||||
pub fn independent_segments_tag(&self) -> Option<ExtXIndependentSegments> {
|
||||
pub const fn independent_segments_tag(&self) -> Option<ExtXIndependentSegments> {
|
||||
self.independent_segments_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-START` tag contained in the playlist.
|
||||
pub fn start_tag(&self) -> Option<ExtXStart> {
|
||||
pub const fn start_tag(&self) -> Option<ExtXStart> {
|
||||
self.start_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-ENDLIST` tag contained in the playlist.
|
||||
pub fn end_list_tag(&self) -> Option<ExtXEndList> {
|
||||
pub const fn end_list_tag(&self) -> Option<ExtXEndList> {
|
||||
self.end_list_tag
|
||||
}
|
||||
|
||||
|
@ -251,6 +254,7 @@ impl MediaPlaylist {
|
|||
&self.segments
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for MediaPlaylist {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "{}", ExtM3u)?;
|
||||
|
@ -285,6 +289,7 @@ impl fmt::Display for MediaPlaylist {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for MediaPlaylist {
|
||||
type Err = Error;
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
|
@ -297,6 +302,7 @@ impl FromStr for MediaPlaylist {
|
|||
pub struct MediaPlaylistOptions {
|
||||
allowable_excess_duration: Duration,
|
||||
}
|
||||
|
||||
impl MediaPlaylistOptions {
|
||||
/// Makes a new `MediaPlaylistOptions` with the default settings.
|
||||
pub fn new() -> Self {
|
||||
|
@ -450,6 +456,7 @@ impl MediaPlaylistOptions {
|
|||
track!(builder.finish())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MediaPlaylistOptions {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
|
|
|
@ -19,6 +19,7 @@ pub struct MediaSegmentBuilder {
|
|||
inf_tag: Option<ExtInf>,
|
||||
uri: Option<SingleLineString>,
|
||||
}
|
||||
|
||||
impl MediaSegmentBuilder {
|
||||
/// Makes a new `MediaSegmentBuilder` instance.
|
||||
pub fn new() -> Self {
|
||||
|
@ -70,6 +71,7 @@ impl MediaSegmentBuilder {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MediaSegmentBuilder {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
|
@ -88,6 +90,7 @@ pub struct MediaSegment {
|
|||
inf_tag: ExtInf,
|
||||
uri: SingleLineString,
|
||||
}
|
||||
|
||||
impl fmt::Display for MediaSegment {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for t in &self.key_tags {
|
||||
|
@ -113,19 +116,20 @@ impl fmt::Display for MediaSegment {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl MediaSegment {
|
||||
/// Returns the URI of the media segment.
|
||||
pub fn uri(&self) -> &SingleLineString {
|
||||
pub const fn uri(&self) -> &SingleLineString {
|
||||
&self.uri
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-INF` tag associated with the media segment.
|
||||
pub fn inf_tag(&self) -> &ExtInf {
|
||||
pub const fn inf_tag(&self) -> &ExtInf {
|
||||
&self.inf_tag
|
||||
}
|
||||
|
||||
/// Returns the `EXT-X-BYTERANGE` tag associated with the media segment.
|
||||
pub fn byte_range_tag(&self) -> Option<ExtXByteRange> {
|
||||
pub const fn byte_range_tag(&self) -> Option<ExtXByteRange> {
|
||||
self.byte_range_tag
|
||||
}
|
||||
|
||||
|
@ -135,7 +139,7 @@ impl MediaSegment {
|
|||
}
|
||||
|
||||
/// Returns the `EXT-X-DISCONTINUITY` tag associated with the media segment.
|
||||
pub fn discontinuity_tag(&self) -> Option<ExtXDiscontinuity> {
|
||||
pub const fn discontinuity_tag(&self) -> Option<ExtXDiscontinuity> {
|
||||
self.discontinuity_tag
|
||||
}
|
||||
|
||||
|
|
|
@ -8,21 +8,25 @@ use std::str::FromStr;
|
|||
/// [4.3.1.1. EXTM3U]: https://tools.ietf.org/html/rfc8216#section-4.3.1.1
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct ExtM3u;
|
||||
|
||||
impl ExtM3u {
|
||||
pub(crate) const PREFIX: &'static str = "#EXTM3U";
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ExtM3u {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Self::PREFIX.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for ExtM3u {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert_eq!(s, Self::PREFIX, ErrorKind::InvalidInput);
|
||||
Ok(ExtM3u)
|
||||
|
|
|
@ -15,17 +15,17 @@ impl ExtXVersion {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-VERSION:";
|
||||
|
||||
/// Makes a new `ExtXVersion` tag.
|
||||
pub fn new(version: ProtocolVersion) -> Self {
|
||||
pub const fn new(version: ProtocolVersion) -> Self {
|
||||
ExtXVersion { version }
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version of the playlist containing this tag.
|
||||
pub fn version(self) -> ProtocolVersion {
|
||||
pub const fn version(&self) -> ProtocolVersion {
|
||||
self.version
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,17 +37,17 @@ impl ExtXIFrameStreamInf {
|
|||
}
|
||||
|
||||
/// Returns the URI that identifies the associated media playlist.
|
||||
pub fn uri(&self) -> &String {
|
||||
pub const fn uri(&self) -> &String {
|
||||
&self.uri
|
||||
}
|
||||
|
||||
/// Returns the peak segment bit rate of the variant stream.
|
||||
pub fn bandwidth(&self) -> u64 {
|
||||
pub const fn bandwidth(&self) -> u64 {
|
||||
self.bandwidth
|
||||
}
|
||||
|
||||
/// Returns the average segment bit rate of the variant stream.
|
||||
pub fn average_bandwidth(&self) -> Option<u64> {
|
||||
pub const fn average_bandwidth(&self) -> Option<u64> {
|
||||
self.average_bandwidth
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,12 @@ impl ExtXIFrameStreamInf {
|
|||
}
|
||||
|
||||
/// Returns the optimal pixel resolution at which to display all the video in the variant stream.
|
||||
pub fn resolution(&self) -> Option<DecimalResolution> {
|
||||
pub const fn resolution(&self) -> Option<DecimalResolution> {
|
||||
self.resolution
|
||||
}
|
||||
|
||||
/// Returns the HDCP level of the variant stream.
|
||||
pub fn hdcp_level(&self) -> Option<HdcpLevel> {
|
||||
pub const fn hdcp_level(&self) -> Option<HdcpLevel> {
|
||||
self.hdcp_level
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ impl ExtXIFrameStreamInf {
|
|||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ impl fmt::Display for ExtXIFrameStreamInf {
|
|||
|
||||
impl FromStr for ExtXIFrameStreamInf {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ pub struct ExtXMediaBuilder {
|
|||
|
||||
impl ExtXMediaBuilder {
|
||||
/// Makes a `ExtXMediaBuilder` instance.
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
ExtXMediaBuilder {
|
||||
media_type: None,
|
||||
uri: None,
|
||||
|
@ -194,17 +194,17 @@ impl ExtXMedia {
|
|||
}
|
||||
|
||||
/// Returns the type of the media associated with this tag.
|
||||
pub fn media_type(&self) -> MediaType {
|
||||
pub const fn media_type(&self) -> MediaType {
|
||||
self.media_type
|
||||
}
|
||||
|
||||
/// Returns the identifier that specifies the group to which the rendition belongs.
|
||||
pub fn group_id(&self) -> &String {
|
||||
pub const fn group_id(&self) -> &String {
|
||||
&self.group_id
|
||||
}
|
||||
|
||||
/// Returns a human-readable description of the rendition.
|
||||
pub fn name(&self) -> &String {
|
||||
pub const fn name(&self) -> &String {
|
||||
&self.name
|
||||
}
|
||||
|
||||
|
@ -224,23 +224,23 @@ impl ExtXMedia {
|
|||
}
|
||||
|
||||
/// Returns whether this is the default rendition.
|
||||
pub fn default(&self) -> bool {
|
||||
pub const fn default(&self) -> bool {
|
||||
self.default
|
||||
}
|
||||
|
||||
/// Returns whether the client may choose to
|
||||
/// play this rendition in the absence of explicit user preference.
|
||||
pub fn autoselect(&self) -> bool {
|
||||
pub const fn autoselect(&self) -> bool {
|
||||
self.autoselect
|
||||
}
|
||||
|
||||
/// Returns whether the rendition contains content that is considered essential to play.
|
||||
pub fn forced(&self) -> bool {
|
||||
pub const fn forced(&self) -> bool {
|
||||
self.forced
|
||||
}
|
||||
|
||||
/// Returns the identifier that specifies a rendition within the segments in the media playlist.
|
||||
pub fn instream_id(&self) -> Option<InStreamId> {
|
||||
pub const fn instream_id(&self) -> Option<InStreamId> {
|
||||
self.instream_id
|
||||
}
|
||||
|
||||
|
@ -308,6 +308,7 @@ impl fmt::Display for ExtXMedia {
|
|||
|
||||
impl FromStr for ExtXMedia {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ impl ExtXSessionData {
|
|||
}
|
||||
|
||||
/// Returns the identifier of the data.
|
||||
pub fn data_id(&self) -> &String {
|
||||
pub const fn data_id(&self) -> &String {
|
||||
&self.data_id
|
||||
}
|
||||
|
||||
/// Returns the session data.
|
||||
pub fn data(&self) -> &SessionData {
|
||||
pub const fn data(&self) -> &SessionData {
|
||||
&self.data
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl ExtXSessionData {
|
|||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ impl fmt::Display for ExtXSessionData {
|
|||
|
||||
impl FromStr for ExtXSessionData {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@ impl ExtXSessionKey {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-SESSION-KEY:";
|
||||
|
||||
/// Makes a new `ExtXSessionKey` tag.
|
||||
pub fn new(key: DecryptionKey) -> Self {
|
||||
pub const fn new(key: DecryptionKey) -> Self {
|
||||
ExtXSessionKey { key }
|
||||
}
|
||||
|
||||
/// Returns a decryption key for the playlist.
|
||||
pub fn key(&self) -> &DecryptionKey {
|
||||
pub const fn key(&self) -> &DecryptionKey {
|
||||
&self.key
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ impl ExtXStreamInf {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-STREAM-INF:";
|
||||
|
||||
/// Makes a new `ExtXStreamInf` tag.
|
||||
pub fn new(uri: SingleLineString, bandwidth: u64) -> Self {
|
||||
pub const fn new(uri: SingleLineString, bandwidth: u64) -> Self {
|
||||
ExtXStreamInf {
|
||||
uri,
|
||||
bandwidth,
|
||||
|
@ -47,17 +47,17 @@ impl ExtXStreamInf {
|
|||
}
|
||||
|
||||
/// Returns the URI that identifies the associated media playlist.
|
||||
pub fn uri(&self) -> &SingleLineString {
|
||||
pub const fn uri(&self) -> &SingleLineString {
|
||||
&self.uri
|
||||
}
|
||||
|
||||
/// Returns the peak segment bit rate of the variant stream.
|
||||
pub fn bandwidth(&self) -> u64 {
|
||||
pub const fn bandwidth(&self) -> u64 {
|
||||
self.bandwidth
|
||||
}
|
||||
|
||||
/// Returns the average segment bit rate of the variant stream.
|
||||
pub fn average_bandwidth(&self) -> Option<u64> {
|
||||
pub const fn average_bandwidth(&self) -> Option<u64> {
|
||||
self.average_bandwidth
|
||||
}
|
||||
|
||||
|
@ -67,17 +67,17 @@ impl ExtXStreamInf {
|
|||
}
|
||||
|
||||
/// Returns the optimal pixel resolution at which to display all the video in the variant stream.
|
||||
pub fn resolution(&self) -> Option<DecimalResolution> {
|
||||
pub const fn resolution(&self) -> Option<DecimalResolution> {
|
||||
self.resolution
|
||||
}
|
||||
|
||||
/// Returns the maximum frame rate for all the video in the variant stream.
|
||||
pub fn frame_rate(&self) -> Option<DecimalFloatingPoint> {
|
||||
pub const fn frame_rate(&self) -> Option<DecimalFloatingPoint> {
|
||||
self.frame_rate
|
||||
}
|
||||
|
||||
/// Returns the HDCP level of the variant stream.
|
||||
pub fn hdcp_level(&self) -> Option<HdcpLevel> {
|
||||
pub const fn hdcp_level(&self) -> Option<HdcpLevel> {
|
||||
self.hdcp_level
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ impl ExtXStreamInf {
|
|||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +145,7 @@ impl fmt::Display for ExtXStreamInf {
|
|||
|
||||
impl FromStr for ExtXStreamInf {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
let mut lines = s.splitn(2, '\n');
|
||||
let first_line = lines.next().expect("Never fails").trim_end_matches('\r');
|
||||
|
|
|
@ -16,18 +16,18 @@ impl ExtXDiscontinuitySequence {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-DISCONTINUITY-SEQUENCE:";
|
||||
|
||||
/// Makes a new `ExtXDiscontinuitySequence` tag.
|
||||
pub fn new(seq_num: u64) -> Self {
|
||||
pub const fn new(seq_num: u64) -> Self {
|
||||
ExtXDiscontinuitySequence { seq_num }
|
||||
}
|
||||
|
||||
/// Returns the discontinuity sequence number of
|
||||
/// the first media segment that appears in the associated playlist.
|
||||
pub fn seq_num(self) -> u64 {
|
||||
pub const fn seq_num(self) -> u64 {
|
||||
self.seq_num
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ impl fmt::Display for ExtXDiscontinuitySequence {
|
|||
|
||||
impl FromStr for ExtXDiscontinuitySequence {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
let seq_num = may_invalid!(s.split_at(Self::PREFIX.len()).1.parse())?;
|
||||
|
|
|
@ -12,17 +12,20 @@ impl ExtXEndList {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-ENDLIST";
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ExtXEndList {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Self::PREFIX.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for ExtXEndList {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert_eq!(s, Self::PREFIX, ErrorKind::InvalidInput);
|
||||
Ok(ExtXEndList)
|
||||
|
|
|
@ -13,7 +13,7 @@ impl ExtXIFramesOnly {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-I-FRAMES-ONLY";
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(self) -> ProtocolVersion {
|
||||
ProtocolVersion::V4
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ impl fmt::Display for ExtXIFramesOnly {
|
|||
|
||||
impl FromStr for ExtXIFramesOnly {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert_eq!(s, Self::PREFIX, ErrorKind::InvalidInput);
|
||||
Ok(ExtXIFramesOnly)
|
||||
|
|
|
@ -16,17 +16,17 @@ impl ExtXMediaSequence {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-MEDIA-SEQUENCE:";
|
||||
|
||||
/// Makes a new `ExtXMediaSequence` tag.
|
||||
pub fn new(seq_num: u64) -> Self {
|
||||
pub const fn new(seq_num: u64) -> Self {
|
||||
ExtXMediaSequence { seq_num }
|
||||
}
|
||||
|
||||
/// Returns the sequence number of the first media segment that appears in the associated playlist.
|
||||
pub fn seq_num(self) -> u64 {
|
||||
pub const fn seq_num(self) -> u64 {
|
||||
self.seq_num
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ impl fmt::Display for ExtXMediaSequence {
|
|||
|
||||
impl FromStr for ExtXMediaSequence {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
let seq_num = may_invalid!(s.split_at(Self::PREFIX.len()).1.parse())?;
|
||||
|
|
|
@ -16,17 +16,17 @@ impl ExtXPlaylistType {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-PLAYLIST-TYPE:";
|
||||
|
||||
/// Makes a new `ExtXPlaylistType` tag.
|
||||
pub fn new(playlist_type: PlaylistType) -> Self {
|
||||
pub const fn new(playlist_type: PlaylistType) -> Self {
|
||||
ExtXPlaylistType { playlist_type }
|
||||
}
|
||||
|
||||
/// Returns the type of the associated media playlist.
|
||||
pub fn playlist_type(self) -> PlaylistType {
|
||||
pub const fn playlist_type(self) -> PlaylistType {
|
||||
self.playlist_type
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ impl fmt::Display for ExtXPlaylistType {
|
|||
|
||||
impl FromStr for ExtXPlaylistType {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
let playlist_type = may_invalid!(s.split_at(Self::PREFIX.len()).1.parse())?;
|
||||
|
|
|
@ -19,18 +19,18 @@ impl ExtXTargetDuration {
|
|||
/// Makes a new `ExtXTargetduration` tag.
|
||||
///
|
||||
/// Note that the nanoseconds part of the `duration` will be discarded.
|
||||
pub fn new(duration: Duration) -> Self {
|
||||
pub const fn new(duration: Duration) -> Self {
|
||||
let duration = Duration::from_secs(duration.as_secs());
|
||||
ExtXTargetDuration { duration }
|
||||
}
|
||||
|
||||
/// Returns the maximum media segment duration in the associated playlist.
|
||||
pub fn duration(&self) -> Duration {
|
||||
pub const fn duration(&self) -> Duration {
|
||||
self.duration
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,17 +16,17 @@ impl ExtXByteRange {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-BYTERANGE:";
|
||||
|
||||
/// Makes a new `ExtXByteRange` tag.
|
||||
pub fn new(range: ByteRange) -> Self {
|
||||
pub const fn new(range: ByteRange) -> Self {
|
||||
ExtXByteRange { range }
|
||||
}
|
||||
|
||||
/// Returns the range of the associated media segment.
|
||||
pub fn range(&self) -> ByteRange {
|
||||
pub const fn range(&self) -> ByteRange {
|
||||
self.range
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V4
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ impl fmt::Display for ExtXByteRange {
|
|||
|
||||
impl FromStr for ExtXByteRange {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
let range = may_invalid!(s.split_at(Self::PREFIX.len()).1.parse())?;
|
||||
|
|
|
@ -32,7 +32,7 @@ impl ExtXDateRange {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-DATERANGE:";
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,17 @@ impl ExtXDiscontinuity {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-DISCONTINUITY";
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ExtXDiscontinuity {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Self::PREFIX.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for ExtXDiscontinuity {
|
||||
type Err = Error;
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
|
|
|
@ -18,7 +18,7 @@ impl ExtInf {
|
|||
pub(crate) const PREFIX: &'static str = "#EXTINF:";
|
||||
|
||||
/// Makes a new `ExtInf` tag.
|
||||
pub fn new(duration: Duration) -> Self {
|
||||
pub const fn new(duration: Duration) -> Self {
|
||||
ExtInf {
|
||||
duration,
|
||||
title: None,
|
||||
|
@ -26,7 +26,7 @@ impl ExtInf {
|
|||
}
|
||||
|
||||
/// Makes a new `ExtInf` tag with the given title.
|
||||
pub fn with_title(duration: Duration, title: SingleLineString) -> Self {
|
||||
pub const fn with_title(duration: Duration, title: SingleLineString) -> Self {
|
||||
ExtInf {
|
||||
duration,
|
||||
title: Some(title),
|
||||
|
@ -34,7 +34,7 @@ impl ExtInf {
|
|||
}
|
||||
|
||||
/// Returns the duration of the associated media segment.
|
||||
pub fn duration(&self) -> Duration {
|
||||
pub const fn duration(&self) -> Duration {
|
||||
self.duration
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ impl ExtXKey {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-KEY:";
|
||||
|
||||
/// Makes a new `ExtXKey` tag.
|
||||
pub fn new(key: DecryptionKey) -> Self {
|
||||
pub const fn new(key: DecryptionKey) -> Self {
|
||||
ExtXKey { key: Some(key) }
|
||||
}
|
||||
|
||||
/// Makes a new `ExtXKey` tag without a decryption key.
|
||||
///
|
||||
/// This tag has the `METHDO=NONE` attribute.
|
||||
pub fn new_without_key() -> Self {
|
||||
pub const fn new_without_key() -> Self {
|
||||
ExtXKey { key: None }
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ impl fmt::Display for ExtXKey {
|
|||
|
||||
impl FromStr for ExtXKey {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
let suffix = s.split_at(Self::PREFIX.len()).1;
|
||||
|
|
|
@ -34,17 +34,17 @@ impl ExtXMap {
|
|||
}
|
||||
|
||||
/// Returns the URI that identifies a resource that contains the media initialization section.
|
||||
pub fn uri(&self) -> &String {
|
||||
pub const fn uri(&self) -> &String {
|
||||
&self.uri
|
||||
}
|
||||
|
||||
/// Returns the range of the media initialization section.
|
||||
pub fn range(&self) -> Option<ByteRange> {
|
||||
pub const fn range(&self) -> Option<ByteRange> {
|
||||
self.range
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V6
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ impl fmt::Display for ExtXMap {
|
|||
|
||||
impl FromStr for ExtXMap {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
|
||||
|
|
|
@ -15,17 +15,17 @@ impl ExtXProgramDateTime {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-PROGRAM-DATE-TIME:";
|
||||
|
||||
/// Makes a new `ExtXProgramDateTime` tag.
|
||||
pub fn new(date_time: SingleLineString) -> Self {
|
||||
pub const fn new(date_time: SingleLineString) -> Self {
|
||||
ExtXProgramDateTime { date_time }
|
||||
}
|
||||
|
||||
/// Returns the date-time of the first sample of the associated media segment.
|
||||
pub fn date_time(&self) -> &SingleLineString {
|
||||
pub const fn date_time(&self) -> &SingleLineString {
|
||||
&self.date_time
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ impl fmt::Display for ExtXProgramDateTime {
|
|||
|
||||
impl FromStr for ExtXProgramDateTime {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
let suffix = s.split_at(Self::PREFIX.len()).1;
|
||||
|
|
|
@ -12,7 +12,7 @@ impl ExtXIndependentSegments {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-INDEPENDENT-SEGMENTS";
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ impl fmt::Display for ExtXIndependentSegments {
|
|||
|
||||
impl FromStr for ExtXIndependentSegments {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert_eq!(s, Self::PREFIX, ErrorKind::InvalidInput);
|
||||
Ok(ExtXIndependentSegments)
|
||||
|
|
|
@ -18,7 +18,7 @@ impl ExtXStart {
|
|||
pub(crate) const PREFIX: &'static str = "#EXT-X-START:";
|
||||
|
||||
/// Makes a new `ExtXStart` tag.
|
||||
pub fn new(time_offset: SignedDecimalFloatingPoint) -> Self {
|
||||
pub const fn new(time_offset: SignedDecimalFloatingPoint) -> Self {
|
||||
ExtXStart {
|
||||
time_offset,
|
||||
precise: false,
|
||||
|
@ -26,7 +26,7 @@ impl ExtXStart {
|
|||
}
|
||||
|
||||
/// Makes a new `ExtXStart` tag with the given `precise` flag.
|
||||
pub fn with_precise(time_offset: SignedDecimalFloatingPoint, precise: bool) -> Self {
|
||||
pub const fn with_precise(time_offset: SignedDecimalFloatingPoint, precise: bool) -> Self {
|
||||
ExtXStart {
|
||||
time_offset,
|
||||
precise,
|
||||
|
@ -34,18 +34,18 @@ impl ExtXStart {
|
|||
}
|
||||
|
||||
/// Returns the time offset of the media segments in the playlist.
|
||||
pub fn time_offset(&self) -> SignedDecimalFloatingPoint {
|
||||
pub const fn time_offset(&self) -> SignedDecimalFloatingPoint {
|
||||
self.time_offset
|
||||
}
|
||||
|
||||
/// Returns whether clients should not render media stream whose presentation times are
|
||||
/// prior to the specified time offset.
|
||||
pub fn precise(&self) -> bool {
|
||||
pub const fn precise(&self) -> bool {
|
||||
self.precise
|
||||
}
|
||||
|
||||
/// Returns the protocol compatibility version that this tag requires.
|
||||
pub fn requires_version(&self) -> ProtocolVersion {
|
||||
pub const fn requires_version(&self) -> ProtocolVersion {
|
||||
ProtocolVersion::V1
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ impl fmt::Display for ExtXStart {
|
|||
|
||||
impl FromStr for ExtXStart {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
track_assert!(s.starts_with(Self::PREFIX), ErrorKind::InvalidInput);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ impl DecimalFloatingPoint {
|
|||
}
|
||||
|
||||
/// Converts `DecimalFloatingPoint` to `f64`.
|
||||
pub fn as_f64(self) -> f64 {
|
||||
pub const fn as_f64(self) -> f64 {
|
||||
self.0
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ impl SignedDecimalFloatingPoint {
|
|||
}
|
||||
|
||||
/// Converts `DecimalFloatingPoint` to `f64`.
|
||||
pub fn as_f64(self) -> f64 {
|
||||
pub const fn as_f64(self) -> f64 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue