mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-06-16 03:50:34 +00:00
Switch to 2018-edition
This commit is contained in:
parent
625d037b27
commit
02d7c80b2b
|
@ -8,6 +8,7 @@ repository = "https://github.com/sile/hls_m3u8"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
keywords = ["hls", "m3u8"]
|
keywords = ["hls", "m3u8"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
travis-ci = {repository = "sile/hls_m3u8"}
|
travis-ci = {repository = "sile/hls_m3u8"}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
use crate::{ErrorKind, Result};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use {ErrorKind, Result};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AttributePairs<'a> {
|
pub struct AttributePairs<'a> {
|
||||||
input: &'a str,
|
input: &'a str,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
|
use crate::tags;
|
||||||
|
use crate::types::SingleLineString;
|
||||||
|
use crate::{Error, ErrorKind, Result};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use tags;
|
|
||||||
use types::SingleLineString;
|
|
||||||
use {Error, ErrorKind, Result};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Lines<'a> {
|
pub struct Lines<'a> {
|
||||||
input: &'a str,
|
input: &'a str,
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
|
use crate::line::{Line, Lines, Tag};
|
||||||
|
use crate::tags::{
|
||||||
|
ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData,
|
||||||
|
ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag,
|
||||||
|
};
|
||||||
|
use crate::types::{ClosedCaptions, MediaType, ProtocolVersion, QuotedString};
|
||||||
|
use crate::{Error, ErrorKind, Result};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use line::{Line, Lines, Tag};
|
|
||||||
use tags::{
|
|
||||||
ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData,
|
|
||||||
ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag,
|
|
||||||
};
|
|
||||||
use types::{ClosedCaptions, MediaType, ProtocolVersion, QuotedString};
|
|
||||||
use {Error, ErrorKind, Result};
|
|
||||||
|
|
||||||
/// Master playlist builder.
|
/// Master playlist builder.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct MasterPlaylistBuilder {
|
pub struct MasterPlaylistBuilder {
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
use std::fmt;
|
use crate::line::{Line, Lines, Tag};
|
||||||
use std::iter;
|
use crate::media_segment::{MediaSegment, MediaSegmentBuilder};
|
||||||
use std::str::FromStr;
|
use crate::tags::{
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use line::{Line, Lines, Tag};
|
|
||||||
use media_segment::{MediaSegment, MediaSegmentBuilder};
|
|
||||||
use tags::{
|
|
||||||
ExtM3u, ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, ExtXIndependentSegments,
|
ExtM3u, ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, ExtXIndependentSegments,
|
||||||
ExtXMediaSequence, ExtXPlaylistType, ExtXStart, ExtXTargetDuration, ExtXVersion,
|
ExtXMediaSequence, ExtXPlaylistType, ExtXStart, ExtXTargetDuration, ExtXVersion,
|
||||||
MediaPlaylistTag,
|
MediaPlaylistTag,
|
||||||
};
|
};
|
||||||
use types::ProtocolVersion;
|
use crate::types::ProtocolVersion;
|
||||||
use {Error, ErrorKind, Result};
|
use crate::{Error, ErrorKind, Result};
|
||||||
|
use std::fmt;
|
||||||
|
use std::iter;
|
||||||
|
use std::str::FromStr;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
/// Media playlist builder.
|
/// Media playlist builder.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -122,7 +121,7 @@ impl MediaPlaylistBuilder {
|
||||||
let mut last_range_uri = None;
|
let mut last_range_uri = None;
|
||||||
for s in &self.segments {
|
for s in &self.segments {
|
||||||
// CHECK: `#EXT-X-TARGETDURATION`
|
// CHECK: `#EXT-X-TARGETDURATION`
|
||||||
let mut segment_duration = s.inf_tag().duration();
|
let segment_duration = s.inf_tag().duration();
|
||||||
let rounded_segment_duration = if segment_duration.subsec_nanos() < 500_000_000 {
|
let rounded_segment_duration = if segment_duration.subsec_nanos() < 500_000_000 {
|
||||||
Duration::from_secs(segment_duration.as_secs())
|
Duration::from_secs(segment_duration.as_secs())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use std::fmt;
|
use crate::tags::{
|
||||||
use std::iter;
|
|
||||||
|
|
||||||
use tags::{
|
|
||||||
ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtXProgramDateTime,
|
ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtXProgramDateTime,
|
||||||
MediaSegmentTag,
|
MediaSegmentTag,
|
||||||
};
|
};
|
||||||
use types::{ProtocolVersion, SingleLineString};
|
use crate::types::{ProtocolVersion, SingleLineString};
|
||||||
use {ErrorKind, Result};
|
use crate::{ErrorKind, Result};
|
||||||
|
use std::fmt;
|
||||||
|
use std::iter;
|
||||||
|
|
||||||
/// Media segment builder.
|
/// Media segment builder.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
use crate::types::ProtocolVersion;
|
||||||
|
use crate::{Error, ErrorKind, Result};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use types::ProtocolVersion;
|
|
||||||
use {Error, ErrorKind, Result};
|
|
||||||
|
|
||||||
/// [4.3.1.1. EXTM3U]
|
/// [4.3.1.1. EXTM3U]
|
||||||
///
|
///
|
||||||
/// [4.3.1.1. EXTM3U]: https://tools.ietf.org/html/rfc8216#section-4.3.1.1
|
/// [4.3.1.1. EXTM3U]: https://tools.ietf.org/html/rfc8216#section-4.3.1.1
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use std::fmt;
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use super::{parse_u64, parse_yes_or_no};
|
use super::{parse_u64, parse_yes_or_no};
|
||||||
use attribute::AttributePairs;
|
use crate::attribute::AttributePairs;
|
||||||
use types::{
|
use crate::types::{
|
||||||
ClosedCaptions, DecimalFloatingPoint, DecimalResolution, DecryptionKey, HdcpLevel, InStreamId,
|
ClosedCaptions, DecimalFloatingPoint, DecimalResolution, DecryptionKey, HdcpLevel, InStreamId,
|
||||||
MediaType, ProtocolVersion, QuotedString, SessionData, SingleLineString,
|
MediaType, ProtocolVersion, QuotedString, SessionData, SingleLineString,
|
||||||
};
|
};
|
||||||
use {Error, ErrorKind, Result};
|
use crate::{Error, ErrorKind, Result};
|
||||||
|
use std::fmt;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// `ExtXMedia` builder.
|
/// `ExtXMedia` builder.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -498,7 +497,7 @@ impl FromStr for ExtXStreamInf {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
fn from_str(s: &str) -> Result<Self> {
|
fn from_str(s: &str) -> Result<Self> {
|
||||||
let mut lines = s.splitn(2, '\n');
|
let mut lines = s.splitn(2, '\n');
|
||||||
let first_line = lines.next().expect("Never fails").trim_right_matches('\r');
|
let first_line = lines.next().expect("Never fails").trim_end_matches('\r');
|
||||||
let second_line = track_assert_some!(lines.next(), ErrorKind::InvalidInput);
|
let second_line = track_assert_some!(lines.next(), ErrorKind::InvalidInput);
|
||||||
|
|
||||||
track_assert!(
|
track_assert!(
|
||||||
|
@ -837,7 +836,7 @@ impl FromStr for ExtXSessionKey {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use types::{EncryptionMethod, InitializationVector};
|
use crate::types::{EncryptionMethod, InitializationVector};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ext_x_media() {
|
fn ext_x_media() {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
use super::parse_yes_or_no;
|
||||||
|
use crate::attribute::AttributePairs;
|
||||||
|
use crate::types::{ProtocolVersion, SignedDecimalFloatingPoint};
|
||||||
|
use crate::{Error, ErrorKind, Result};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use super::parse_yes_or_no;
|
|
||||||
use attribute::AttributePairs;
|
|
||||||
use types::{ProtocolVersion, SignedDecimalFloatingPoint};
|
|
||||||
use {Error, ErrorKind, Result};
|
|
||||||
|
|
||||||
/// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS]
|
/// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS]
|
||||||
///
|
///
|
||||||
/// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS]: https://tools.ietf.org/html/rfc8216#section-4.3.5.1
|
/// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS]: https://tools.ietf.org/html/rfc8216#section-4.3.5.1
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
|
use crate::types::{PlaylistType, ProtocolVersion};
|
||||||
|
use crate::{Error, ErrorKind, Result};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use trackable::error::ErrorKindExt;
|
use trackable::error::ErrorKindExt;
|
||||||
|
|
||||||
use types::{PlaylistType, ProtocolVersion};
|
|
||||||
use {Error, ErrorKind, Result};
|
|
||||||
|
|
||||||
/// [4.3.3.1. EXT-X-TARGETDURATION]
|
/// [4.3.3.1. EXT-X-TARGETDURATION]
|
||||||
///
|
///
|
||||||
/// [4.3.3.1. EXT-X-TARGETDURATION]: https://tools.ietf.org/html/rfc8216#section-4.3.3.1
|
/// [4.3.3.1. EXT-X-TARGETDURATION]: https://tools.ietf.org/html/rfc8216#section-4.3.3.1
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
|
use crate::attribute::AttributePairs;
|
||||||
|
use crate::types::{
|
||||||
|
ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, SingleLineString,
|
||||||
|
};
|
||||||
|
use crate::{Error, ErrorKind, Result};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use trackable::error::ErrorKindExt;
|
use trackable::error::ErrorKindExt;
|
||||||
|
|
||||||
use attribute::AttributePairs;
|
|
||||||
use types::{
|
|
||||||
ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, SingleLineString,
|
|
||||||
};
|
|
||||||
use {Error, ErrorKind, Result};
|
|
||||||
|
|
||||||
/// [4.3.2.1. EXTINF]
|
/// [4.3.2.1. EXTINF]
|
||||||
///
|
///
|
||||||
/// [4.3.2.1. EXTINF]: https://tools.ietf.org/html/rfc8216#section-4.3.2.1
|
/// [4.3.2.1. EXTINF]: https://tools.ietf.org/html/rfc8216#section-4.3.2.1
|
||||||
|
@ -479,10 +478,9 @@ impl FromStr for ExtXDateRange {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use types::{EncryptionMethod, InitializationVector};
|
use crate::types::{EncryptionMethod, InitializationVector};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn extinf() {
|
fn extinf() {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
//! [4.3. Playlist Tags]
|
//! [4.3. Playlist Tags]
|
||||||
//!
|
//!
|
||||||
//! [4.3. Playlist Tags]: https://tools.ietf.org/html/rfc8216#section-4.3
|
//! [4.3. Playlist Tags]: https://tools.ietf.org/html/rfc8216#section-4.3
|
||||||
|
use crate::{ErrorKind, Result};
|
||||||
use trackable::error::ErrorKindExt;
|
use trackable::error::ErrorKindExt;
|
||||||
|
|
||||||
use {ErrorKind, Result};
|
|
||||||
|
|
||||||
macro_rules! may_invalid {
|
macro_rules! may_invalid {
|
||||||
($expr:expr) => {
|
($expr:expr) => {
|
||||||
$expr.map_err(|e| track!(Error::from(ErrorKind::InvalidInput.cause(e))))
|
$expr.map_err(|e| track!(Error::from(ErrorKind::InvalidInput.cause(e))))
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
//! Miscellaneous types.
|
//! Miscellaneous types.
|
||||||
|
use crate::attribute::AttributePairs;
|
||||||
|
use crate::{Error, ErrorKind, Result};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::str::{self, FromStr};
|
use std::str::{self, FromStr};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use trackable::error::ErrorKindExt;
|
use trackable::error::ErrorKindExt;
|
||||||
|
|
||||||
use attribute::AttributePairs;
|
|
||||||
use {Error, ErrorKind, Result};
|
|
||||||
|
|
||||||
/// String that represents a single line in a playlist file.
|
/// String that represents a single line in a playlist file.
|
||||||
///
|
///
|
||||||
/// See: [4.1. Definition of a Playlist]
|
/// See: [4.1. Definition of a Playlist]
|
||||||
|
|
Loading…
Reference in a new issue