1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-05-05 10:09:07 +00:00

fix rust_2018_idioms

This commit is contained in:
Luro02 2020-04-09 08:43:13 +02:00
parent f90ea7a121
commit f0d91c5e7c
No known key found for this signature in database
GPG key ID: B66FD4F74501A9CF
37 changed files with 37 additions and 39 deletions

View file

@ -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)]

View file

@ -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,

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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)
}

View file

@ -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)?;

View file

@ -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))?;

View file

@ -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())
}
}

View file

@ -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)?;

View file

@ -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)
}

View file

@ -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 {

View file

@ -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 {

View file

@ -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)
}

View file

@ -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())
}
}

View file

@ -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(())

View file

@ -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))?;

View file

@ -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 {

View file

@ -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())?;

View file

@ -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 {

View file

@ -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))?;

View file

@ -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")]
{

View file

@ -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 {

View file

@ -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)?;

View file

@ -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 {

View file

@ -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(())

View file

@ -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"),

View file

@ -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)?;

View file

@ -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 {

View file

@ -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];

View file

@ -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`].

View file

@ -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"));
}

View file

@ -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),

View file

@ -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"),

View file

@ -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 {

View file

@ -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)),