1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-12-23 12:30:29 +00:00

Apply rustfmt-0.99.1

This commit is contained in:
Takeru Ohta 2018-10-04 20:18:56 +09:00
parent c0597a2e5b
commit 8585016720
12 changed files with 58 additions and 52 deletions

View file

@ -3,9 +3,9 @@ extern crate hls_m3u8;
#[macro_use] #[macro_use]
extern crate trackable; extern crate trackable;
use std::io::{self, Read};
use clap::{App, Arg}; use clap::{App, Arg};
use hls_m3u8::{MasterPlaylist, MediaPlaylist}; use hls_m3u8::{MasterPlaylist, MediaPlaylist};
use std::io::{self, Read};
use trackable::error::Failure; use trackable::error::Failure;
fn main() { fn main() {
@ -16,8 +16,7 @@ fn main() {
.takes_value(true) .takes_value(true)
.default_value("media") .default_value("media")
.possible_values(&["media", "master"]), .possible_values(&["media", "master"]),
) ).get_matches();
.get_matches();
let mut m3u8 = String::new(); let mut m3u8 = String::new();
track_try_unwrap!( track_try_unwrap!(
io::stdin() io::stdin()

View file

@ -1,9 +1,9 @@
use std::fmt; use std::fmt;
use std::str::FromStr; use std::str::FromStr;
use {Error, ErrorKind, Result};
use tags; use tags;
use types::SingleLineString; use types::SingleLineString;
use {Error, ErrorKind, Result};
#[derive(Debug)] #[derive(Debug)]
pub struct Lines<'a> { pub struct Lines<'a> {

View file

@ -1,13 +1,15 @@
use std::collections::HashSet; use std::collections::HashSet;
use std::iter;
use std::fmt; use std::fmt;
use std::iter;
use std::str::FromStr; use std::str::FromStr;
use {Error, ErrorKind, Result};
use line::{Line, Lines, Tag}; use line::{Line, Lines, Tag};
use tags::{ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData, use tags::{
ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag}; ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData,
ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag,
};
use types::{ClosedCaptions, MediaType, ProtocolVersion, QuotedString}; use types::{ClosedCaptions, MediaType, ProtocolVersion, QuotedString};
use {Error, ErrorKind, Result};
/// Master playlist builder. /// Master playlist builder.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -100,16 +102,14 @@ impl MasterPlaylistBuilder {
self.independent_segments_tag self.independent_segments_tag
.iter() .iter()
.map(|t| t.requires_version()), .map(|t| t.requires_version()),
) ).chain(self.start_tag.iter().map(|t| t.requires_version()))
.chain(self.start_tag.iter().map(|t| t.requires_version()))
.chain(self.media_tags.iter().map(|t| t.requires_version())) .chain(self.media_tags.iter().map(|t| t.requires_version()))
.chain(self.stream_inf_tags.iter().map(|t| t.requires_version())) .chain(self.stream_inf_tags.iter().map(|t| t.requires_version()))
.chain( .chain(
self.i_frame_stream_inf_tags self.i_frame_stream_inf_tags
.iter() .iter()
.map(|t| t.requires_version()), .map(|t| t.requires_version()),
) ).chain(self.session_data_tags.iter().map(|t| t.requires_version()))
.chain(self.session_data_tags.iter().map(|t| t.requires_version()))
.chain(self.session_key_tags.iter().map(|t| t.requires_version())) .chain(self.session_key_tags.iter().map(|t| t.requires_version()))
.max() .max()
.expect("Never fails") .expect("Never fails")

View file

@ -3,13 +3,15 @@ use std::iter;
use std::str::FromStr; use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use {Error, ErrorKind, Result};
use line::{Line, Lines, Tag}; use line::{Line, Lines, Tag};
use media_segment::{MediaSegment, MediaSegmentBuilder}; use media_segment::{MediaSegment, MediaSegmentBuilder};
use tags::{ExtM3u, ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, use tags::{
ExtXIndependentSegments, ExtXMediaSequence, ExtXPlaylistType, ExtXStart, ExtM3u, ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, ExtXIndependentSegments,
ExtXTargetDuration, ExtXVersion, MediaPlaylistTag}; ExtXMediaSequence, ExtXPlaylistType, ExtXStart, ExtXTargetDuration, ExtXVersion,
MediaPlaylistTag,
};
use types::ProtocolVersion; use types::ProtocolVersion;
use {Error, ErrorKind, Result};
/// Media playlist builder. /// Media playlist builder.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -148,21 +150,18 @@ impl MediaPlaylistBuilder {
self.target_duration_tag self.target_duration_tag
.iter() .iter()
.map(|t| t.requires_version()), .map(|t| t.requires_version()),
) ).chain(self.media_sequence_tag.iter().map(|t| t.requires_version()))
.chain(self.media_sequence_tag.iter().map(|t| t.requires_version()))
.chain( .chain(
self.discontinuity_sequence_tag self.discontinuity_sequence_tag
.iter() .iter()
.map(|t| t.requires_version()), .map(|t| t.requires_version()),
) ).chain(self.playlist_type_tag.iter().map(|t| t.requires_version()))
.chain(self.playlist_type_tag.iter().map(|t| t.requires_version()))
.chain(self.i_frames_only_tag.iter().map(|t| t.requires_version())) .chain(self.i_frames_only_tag.iter().map(|t| t.requires_version()))
.chain( .chain(
self.independent_segments_tag self.independent_segments_tag
.iter() .iter()
.map(|t| t.requires_version()), .map(|t| t.requires_version()),
) ).chain(self.start_tag.iter().map(|t| t.requires_version()))
.chain(self.start_tag.iter().map(|t| t.requires_version()))
.chain(self.end_list_tag.iter().map(|t| t.requires_version())) .chain(self.end_list_tag.iter().map(|t| t.requires_version()))
.chain(self.segments.iter().map(|s| s.requires_version())) .chain(self.segments.iter().map(|s| s.requires_version()))
.max() .max()

View file

@ -1,10 +1,12 @@
use std::fmt; use std::fmt;
use std::iter; use std::iter;
use {ErrorKind, Result}; use tags::{
use tags::{ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtXProgramDateTime,
ExtXProgramDateTime, MediaSegmentTag}; MediaSegmentTag,
};
use types::{ProtocolVersion, SingleLineString}; use types::{ProtocolVersion, SingleLineString};
use {ErrorKind, Result};
/// Media segment builder. /// Media segment builder.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -165,8 +167,7 @@ impl MediaSegment {
self.program_date_time_tag self.program_date_time_tag
.iter() .iter()
.map(|t| t.requires_version()), .map(|t| t.requires_version()),
) ).chain(iter::once(self.inf_tag.requires_version()))
.chain(iter::once(self.inf_tag.requires_version()))
.max() .max()
.expect("Never fails") .expect("Never fails")
} }

View file

@ -1,8 +1,8 @@
use std::fmt; use std::fmt;
use std::str::FromStr; use std::str::FromStr;
use {Error, ErrorKind, Result};
use types::ProtocolVersion; use types::ProtocolVersion;
use {Error, ErrorKind, Result};
/// [4.3.1.1. EXTM3U] /// [4.3.1.1. EXTM3U]
/// ///

View file

@ -1,11 +1,13 @@
use std::fmt; use std::fmt;
use std::str::FromStr; use std::str::FromStr;
use {Error, ErrorKind, Result}; use super::{parse_u64, parse_yes_or_no};
use attribute::AttributePairs; use attribute::AttributePairs;
use types::{ClosedCaptions, DecimalFloatingPoint, DecimalResolution, DecryptionKey, HdcpLevel, use types::{
InStreamId, MediaType, ProtocolVersion, QuotedString, SessionData, SingleLineString}; ClosedCaptions, DecimalFloatingPoint, DecimalResolution, DecryptionKey, HdcpLevel, InStreamId,
use super::{parse_yes_or_no, parse_u64}; MediaType, ProtocolVersion, QuotedString, SessionData, SingleLineString,
};
use {Error, ErrorKind, Result};
/// `ExtXMedia` builder. /// `ExtXMedia` builder.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -834,8 +836,8 @@ impl FromStr for ExtXSessionKey {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use types::{EncryptionMethod, InitializationVector};
use super::*; use super::*;
use types::{EncryptionMethod, InitializationVector};
#[test] #[test]
fn ext_x_media() { fn ext_x_media() {
@ -899,7 +901,7 @@ mod test {
method: EncryptionMethod::Aes128, method: EncryptionMethod::Aes128,
uri: quoted_string("foo"), uri: quoted_string("foo"),
iv: Some(InitializationVector([ iv: Some(InitializationVector([
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
])), ])),
key_format: None, key_format: None,
key_format_versions: None, key_format_versions: None,

View file

@ -1,10 +1,10 @@
use std::fmt; use std::fmt;
use std::str::FromStr; use std::str::FromStr;
use {Error, ErrorKind, Result}; use super::parse_yes_or_no;
use attribute::AttributePairs; use attribute::AttributePairs;
use types::{ProtocolVersion, SignedDecimalFloatingPoint}; use types::{ProtocolVersion, SignedDecimalFloatingPoint};
use super::parse_yes_or_no; use {Error, ErrorKind, Result};
/// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS] /// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS]
/// ///

View file

@ -3,8 +3,8 @@ use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use trackable::error::ErrorKindExt; use trackable::error::ErrorKindExt;
use {Error, ErrorKind, Result};
use types::{PlaylistType, ProtocolVersion}; use types::{PlaylistType, ProtocolVersion};
use {Error, ErrorKind, Result};
/// [4.3.3.1. EXT-X-TARGETDURATION] /// [4.3.3.1. EXT-X-TARGETDURATION]
/// ///

View file

@ -4,10 +4,11 @@ use std::str::FromStr;
use std::time::Duration; use std::time::Duration;
use trackable::error::ErrorKindExt; use trackable::error::ErrorKindExt;
use {Error, ErrorKind, Result};
use attribute::AttributePairs; use attribute::AttributePairs;
use types::{ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, use types::{
SingleLineString}; ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, SingleLineString,
};
use {Error, ErrorKind, Result};
/// [4.3.2.1. EXTINF] /// [4.3.2.1. EXTINF]
/// ///
@ -480,8 +481,8 @@ impl FromStr for ExtXDateRange {
mod test { mod test {
use std::time::Duration; use std::time::Duration;
use types::{EncryptionMethod, InitializationVector};
use super::*; use super::*;
use types::{EncryptionMethod, InitializationVector};
#[test] #[test]
fn extinf() { fn extinf() {
@ -555,7 +556,7 @@ mod test {
method: EncryptionMethod::Aes128, method: EncryptionMethod::Aes128,
uri: QuotedString::new("foo").unwrap(), uri: QuotedString::new("foo").unwrap(),
iv: Some(InitializationVector([ iv: Some(InitializationVector([
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
])), ])),
key_format: None, key_format: None,
key_format_versions: None, key_format_versions: None,
@ -569,7 +570,7 @@ mod test {
method: EncryptionMethod::Aes128, method: EncryptionMethod::Aes128,
uri: QuotedString::new("foo").unwrap(), uri: QuotedString::new("foo").unwrap(),
iv: Some(InitializationVector([ iv: Some(InitializationVector([
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
])), ])),
key_format: Some(QuotedString::new("baz").unwrap()), key_format: Some(QuotedString::new("baz").unwrap()),
key_format_versions: None, key_format_versions: None,

View file

@ -8,7 +8,7 @@ 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))))
} };
} }
macro_rules! impl_from { macro_rules! impl_from {
@ -18,17 +18,21 @@ macro_rules! impl_from {
$to::$from(f) $to::$from(f)
} }
} }
} };
} }
pub use self::basic::{ExtM3u, ExtXVersion}; pub use self::basic::{ExtM3u, ExtXVersion};
pub use self::master_playlist::{ExtXIFrameStreamInf, ExtXMedia, ExtXSessionData, ExtXSessionKey, pub use self::master_playlist::{
ExtXStreamInf}; ExtXIFrameStreamInf, ExtXMedia, ExtXSessionData, ExtXSessionKey, ExtXStreamInf,
};
pub use self::media_or_master_playlist::{ExtXIndependentSegments, ExtXStart}; pub use self::media_or_master_playlist::{ExtXIndependentSegments, ExtXStart};
pub use self::media_playlist::{ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, pub use self::media_playlist::{
ExtXMediaSequence, ExtXPlaylistType, ExtXTargetDuration}; ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, ExtXMediaSequence, ExtXPlaylistType,
pub use self::media_segment::{ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXTargetDuration,
ExtXMap, ExtXProgramDateTime}; };
pub use self::media_segment::{
ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtXProgramDateTime,
};
mod basic; mod basic;
mod master_playlist; mod master_playlist;

View file

@ -5,8 +5,8 @@ use std::str::{self, FromStr};
use std::time::Duration; use std::time::Duration;
use trackable::error::ErrorKindExt; use trackable::error::ErrorKindExt;
use {Error, ErrorKind, Result};
use attribute::AttributePairs; 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.
/// ///