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

minor improvements

This commit is contained in:
Luro02 2020-02-24 16:45:10 +01:00
parent 6ef8182f2c
commit 6333a80507
No known key found for this signature in database
GPG key ID: B66FD4F74501A9CF
10 changed files with 26 additions and 23 deletions

View file

@ -18,8 +18,6 @@
)]
//! [HLS] m3u8 parser/generator.
//!
//! [HLS]: https://tools.ietf.org/html/rfc8216
//!
//! # Examples
//!
//! ```
@ -38,6 +36,8 @@
//!
//! assert!(m3u8.parse::<MediaPlaylist>().is_ok());
//! ```
//!
//! [HLS]: https://tools.ietf.org/html/rfc8216
pub use error::Error;
pub use master_playlist::MasterPlaylist;

View file

@ -42,6 +42,8 @@ pub struct MediaSegment {
impl MediaSegment {
/// Returns a builder for a [`MediaSegment`].
#[must_use]
#[inline]
pub fn builder() -> MediaSegmentBuilder { MediaSegmentBuilder::default() }
}

View file

@ -220,14 +220,8 @@ impl ExtXMedia {
impl RequiredVersion for ExtXMedia {
fn required_version(&self) -> ProtocolVersion {
match self.instream_id {
None
| Some(InStreamId::Cc1)
| Some(InStreamId::Cc2)
| Some(InStreamId::Cc3)
| Some(InStreamId::Cc4) => ProtocolVersion::V1,
_ => ProtocolVersion::V7,
}
self.instream_id
.map_or(ProtocolVersion::V1, |i| i.required_version())
}
}

View file

@ -192,7 +192,7 @@ mod test {
// EncryptionMethod is None!
#[test]
#[should_panic = "the encryption method should never be `None`"]
fn test_new_panic() { ExtXSessionKey::new(ExtXKey::new(EncryptionMethod::None, "")); }
fn test_new_panic() { let _ = ExtXSessionKey::new(ExtXKey::new(EncryptionMethod::None, "")); }
#[test]
fn test_deref() {

View file

@ -178,6 +178,7 @@ impl ExtXKey {
/// "#EXT-X-KEY:METHOD=AES-128,URI=\"https://www.example.com/\""
/// );
/// ```
#[must_use]
pub fn new<T: Into<String>>(method: EncryptionMethod, uri: T) -> Self {
Self {
method,
@ -207,6 +208,7 @@ impl ExtXKey {
/// .build()?;
/// # Ok::<(), Box<dyn ::std::error::Error>>(())
/// ```
#[must_use]
pub fn builder() -> ExtXKeyBuilder { ExtXKeyBuilder::default() }
/// Makes a new [`ExtXKey`] tag without a decryption key.
@ -219,6 +221,7 @@ impl ExtXKey {
///
/// assert_eq!(key.to_string(), "#EXT-X-KEY:METHOD=NONE");
/// ```
#[must_use]
pub const fn empty() -> Self {
Self {
method: EncryptionMethod::None,
@ -244,6 +247,7 @@ impl ExtXKey {
/// ```
///
/// [`None`]: EncryptionMethod::None
#[must_use]
pub fn is_empty(&self) -> bool { self.method() == EncryptionMethod::None }
}

View file

@ -145,7 +145,8 @@ impl FromStr for ExtXMap {
}
}
let uri = uri.ok_or_else(|| Error::missing_value("EXT-X-URI"))?;
let uri = uri.ok_or_else(|| Error::missing_value("URI"))?;
Ok(Self {
uri,
range,

View file

@ -22,7 +22,9 @@ use crate::Error;
///
/// [RFC6381]: https://tools.ietf.org/html/rfc6381
/// [`VariantStream`]: crate::tags::VariantStream
#[derive(AsMut, AsRef, Deref, DerefMut, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(
AsMut, AsRef, Deref, DerefMut, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default,
)]
pub struct Codecs {
list: Vec<String>,
}
@ -38,7 +40,7 @@ impl Codecs {
/// ```
#[inline]
#[must_use]
pub fn new() -> Self { Self { list: Vec::new() } }
pub const fn new() -> Self { Self { list: Vec::new() } }
}
impl fmt::Display for Codecs {

View file

@ -22,7 +22,7 @@ pub enum EncryptionMethod {
/// # let media_sequence_number = 5;
/// # assert_eq!(
/// format!("0x{:032x}", media_sequence_number)
/// # , "00000000000000000000000000000005".to_string());
/// # , "0x00000000000000000000000000000005".to_string());
/// ```
///
/// [`MediaSegment`]: crate::MediaSegment

View file

@ -277,15 +277,15 @@ mod tests {
#[test]
#[should_panic = "float must be finite: `inf`"]
fn test_new_infinite() { Float::new(::core::f32::INFINITY); }
fn test_new_infinite() { let _ = Float::new(::core::f32::INFINITY); }
#[test]
#[should_panic = "float must be finite: `-inf`"]
fn test_new_neg_infinite() { Float::new(::core::f32::NEG_INFINITY); }
fn test_new_neg_infinite() { let _ = Float::new(::core::f32::NEG_INFINITY); }
#[test]
#[should_panic = "float must not be `NaN`"]
fn test_new_nan() { Float::new(::core::f32::NAN); }
fn test_new_nan() { let _ = Float::new(::core::f32::NAN); }
#[test]
fn test_as_f32() {

View file

@ -266,23 +266,23 @@ mod tests {
#[test]
#[should_panic = "float must be positive: `-1.1`"]
fn test_new_negative() { UFloat::new(-1.1); }
fn test_new_negative() { let _ = UFloat::new(-1.1); }
#[test]
#[should_panic = "float must be positive: `0`"]
fn test_new_negative_zero() { UFloat::new(-0.0); }
fn test_new_negative_zero() { let _ = UFloat::new(-0.0); }
#[test]
#[should_panic = "float must be finite: `inf`"]
fn test_new_infinite() { UFloat::new(::core::f32::INFINITY); }
fn test_new_infinite() { let _ = UFloat::new(::core::f32::INFINITY); }
#[test]
#[should_panic = "float must be finite: `-inf`"]
fn test_new_neg_infinite() { UFloat::new(::core::f32::NEG_INFINITY); }
fn test_new_neg_infinite() { let _ = UFloat::new(::core::f32::NEG_INFINITY); }
#[test]
#[should_panic = "float must not be `NaN`"]
fn test_new_nan() { UFloat::new(::core::f32::NAN); }
fn test_new_nan() { let _ = UFloat::new(::core::f32::NAN); }
#[test]
fn test_as_f32() {