mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-12-23 04:26:27 +00:00
fix rust_2018_idioms
This commit is contained in:
parent
f90ea7a121
commit
f0d91c5e7c
37 changed files with 37 additions and 39 deletions
|
@ -84,7 +84,7 @@ impl PartialEq for Error {
|
|||
impl std::error::Error for Error {}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.inner.fmt(f) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) }
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![doc(html_root_url = "https://docs.rs/hls_m3u8/0.2.1")]
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![warn(
|
||||
clippy::pedantic, //
|
||||
clippy::nursery,
|
||||
|
|
|
@ -410,7 +410,7 @@ impl RequiredVersion for MasterPlaylistBuilder {
|
|||
}
|
||||
|
||||
impl fmt::Display for MasterPlaylist {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
writeln!(f, "{}", ExtM3u)?;
|
||||
|
||||
if self.required_version() != ProtocolVersion::V1 {
|
||||
|
|
|
@ -432,7 +432,7 @@ impl RequiredVersion for MediaPlaylist {
|
|||
}
|
||||
|
||||
impl fmt::Display for MediaPlaylist {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
writeln!(f, "{}", ExtM3u)?;
|
||||
|
||||
if self.required_version() != ProtocolVersion::V1 {
|
||||
|
|
|
@ -202,7 +202,7 @@ impl MediaSegmentBuilder {
|
|||
}
|
||||
|
||||
impl fmt::Display for MediaSegment {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// NOTE: self.keys will be printed by the `MediaPlaylist` to prevent redundance.
|
||||
|
||||
if let Some(value) = &self.map {
|
||||
|
|
|
@ -5,8 +5,6 @@ use crate::types::ProtocolVersion;
|
|||
use crate::utils::tag;
|
||||
use crate::{Error, RequiredVersion};
|
||||
|
||||
/// # [4.3.1.1. EXTM3U]
|
||||
///
|
||||
/// The [`ExtM3u`] tag indicates that the file is an **Ext**ended **[`M3U`]**
|
||||
/// Playlist file.
|
||||
/// It is the at the start of every [`MediaPlaylist`] and [`MasterPlaylist`].
|
||||
|
@ -14,7 +12,6 @@ use crate::{Error, RequiredVersion};
|
|||
/// [`MediaPlaylist`]: crate::MediaPlaylist
|
||||
/// [`MasterPlaylist`]: crate::MasterPlaylist
|
||||
/// [`M3U`]: https://en.wikipedia.org/wiki/M3U
|
||||
/// [4.3.1.1. EXTM3U]: https://tools.ietf.org/html/rfc8216#section-4.3.1.1
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
|
||||
pub(crate) struct ExtM3u;
|
||||
|
||||
|
@ -28,7 +25,7 @@ impl RequiredVersion for ExtM3u {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtM3u {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", Self::PREFIX) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", Self::PREFIX) }
|
||||
}
|
||||
|
||||
impl FromStr for ExtM3u {
|
||||
|
|
|
@ -53,7 +53,7 @@ impl RequiredVersion for ExtXVersion {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXVersion {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
//
|
||||
write!(f, "{}{}", Self::PREFIX, self.0)
|
||||
}
|
||||
|
|
|
@ -333,7 +333,7 @@ impl RequiredVersion for ExtXMedia {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXMedia {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
write!(f, "TYPE={}", self.media_type)?;
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ impl RequiredVersion for ExtXSessionData {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXSessionData {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
write!(f, "DATA-ID={}", quote(&self.data_id))?;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ impl RequiredVersion for ExtXSessionKey {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXSessionKey {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}{}", Self::PREFIX, self.0.to_string())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ impl RequiredVersion for VariantStream {
|
|||
}
|
||||
|
||||
impl fmt::Display for VariantStream {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Self::ExtXIFrame { uri, stream_data } => {
|
||||
write!(f, "{}", Self::PREFIX_EXTXIFRAME)?;
|
||||
|
|
|
@ -22,7 +22,7 @@ impl RequiredVersion for ExtXDiscontinuitySequence {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXDiscontinuitySequence {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
//
|
||||
write!(f, "{}{}", Self::PREFIX, self.0)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ impl RequiredVersion for ExtXEndList {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXEndList {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
}
|
||||
|
||||
impl FromStr for ExtXEndList {
|
||||
|
|
|
@ -18,7 +18,7 @@ impl RequiredVersion for ExtXIFramesOnly {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXIFramesOnly {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
}
|
||||
|
||||
impl FromStr for ExtXIFramesOnly {
|
||||
|
|
|
@ -20,7 +20,7 @@ impl RequiredVersion for ExtXMediaSequence {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXMediaSequence {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
//
|
||||
write!(f, "{}{}", Self::PREFIX, self.0)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ impl RequiredVersion for ExtXTargetDuration {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXTargetDuration {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}{}", Self::PREFIX, self.0.as_secs())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ where
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXByteRange {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
write!(f, "{}", self.0)?;
|
||||
Ok(())
|
||||
|
|
|
@ -452,7 +452,7 @@ impl FromStr for ExtXDateRange {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXDateRange {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
write!(f, "ID={}", quote(&self.id))?;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ impl RequiredVersion for ExtXDiscontinuity {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXDiscontinuity {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
}
|
||||
|
||||
impl FromStr for ExtXDiscontinuity {
|
||||
|
|
|
@ -139,7 +139,7 @@ impl RequiredVersion for ExtInf {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtInf {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
write!(f, "{},", self.duration.as_secs_f64())?;
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ impl From<crate::tags::ExtXSessionKey> for ExtXKey {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXKey {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
|
||||
if let Some(value) = &self.0 {
|
||||
|
|
|
@ -107,7 +107,7 @@ impl RequiredVersion for ExtXMap {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXMap {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
write!(f, "URI={}", quote(&self.uri))?;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ impl RequiredVersion for ExtXProgramDateTime {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXProgramDateTime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let date_time = {
|
||||
#[cfg(feature = "chrono")]
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ impl RequiredVersion for ExtXIndependentSegments {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXIndependentSegments {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Self::PREFIX.fmt(f) }
|
||||
}
|
||||
|
||||
impl FromStr for ExtXIndependentSegments {
|
||||
|
|
|
@ -99,7 +99,7 @@ impl RequiredVersion for ExtXStart {
|
|||
}
|
||||
|
||||
impl fmt::Display for ExtXStart {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", Self::PREFIX)?;
|
||||
write!(f, "TIME-OFFSET={}", self.time_offset)?;
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ impl TryInto<Range<usize>> for ByteRange {
|
|||
}
|
||||
|
||||
impl fmt::Display for ByteRange {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.len())?;
|
||||
|
||||
if let Some(value) = self.start {
|
||||
|
|
|
@ -58,7 +58,7 @@ impl FromStr for Channels {
|
|||
}
|
||||
|
||||
impl fmt::Display for Channels {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.number)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -63,7 +63,7 @@ impl<T: PartialEq<str>> PartialEq<T> for ClosedCaptions {
|
|||
}
|
||||
|
||||
impl fmt::Display for ClosedCaptions {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Self::GroupId(value) => write!(f, "{}", quote(value)),
|
||||
Self::None => write!(f, "NONE"),
|
||||
|
|
|
@ -44,7 +44,7 @@ impl Codecs {
|
|||
}
|
||||
|
||||
impl fmt::Display for Codecs {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if let Some(codec) = self.list.iter().next() {
|
||||
write!(f, "{}", codec)?;
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ impl FromStr for DecryptionKey {
|
|||
}
|
||||
|
||||
impl fmt::Display for DecryptionKey {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "METHOD={},URI={}", self.method, quote(&self.uri))?;
|
||||
|
||||
if let InitializationVector::Aes128(_) = &self.iv {
|
||||
|
|
|
@ -166,7 +166,7 @@ impl From<Option<[u8; 0x10]>> for InitializationVector {
|
|||
}
|
||||
|
||||
impl fmt::Display for InitializationVector {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Self::Aes128(buffer) => {
|
||||
let mut result = [0; 0x10 * 2];
|
||||
|
|
|
@ -33,7 +33,7 @@ impl FromStr for KeyFormat {
|
|||
}
|
||||
|
||||
impl fmt::Display for KeyFormat {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", quote(&"identity")) }
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", quote(&"identity")) }
|
||||
}
|
||||
|
||||
/// This tag requires [`ProtocolVersion::V5`].
|
||||
|
|
|
@ -395,7 +395,7 @@ impl FromStr for KeyFormatVersions {
|
|||
}
|
||||
|
||||
impl fmt::Display for KeyFormatVersions {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.is_default() || self.is_empty() {
|
||||
return write!(f, "{}", quote("1"));
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ impl RequiredVersion for PlaylistType {
|
|||
}
|
||||
|
||||
impl fmt::Display for PlaylistType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Self::Event => write!(f, "{}EVENT", Self::PREFIX),
|
||||
Self::Vod => write!(f, "{}VOD", Self::PREFIX),
|
||||
|
|
|
@ -34,7 +34,7 @@ impl ProtocolVersion {
|
|||
}
|
||||
|
||||
impl fmt::Display for ProtocolVersion {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Self::V1 => write!(f, "1"),
|
||||
Self::V2 => write!(f, "2"),
|
||||
|
|
|
@ -257,7 +257,7 @@ impl StreamData {
|
|||
}
|
||||
|
||||
impl fmt::Display for StreamData {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "BANDWIDTH={}", self.bandwidth)?;
|
||||
|
||||
if let Some(value) = &self.average_bandwidth {
|
||||
|
|
|
@ -18,7 +18,7 @@ pub enum Value {
|
|||
}
|
||||
|
||||
impl fmt::Display for Value {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Self::String(value) => write!(f, "{}", quote(value)),
|
||||
Self::Hex(value) => write!(f, "0x{}", hex::encode_upper(value)),
|
||||
|
|
Loading…
Reference in a new issue