From 1bfad5df01b7ff2e0f20919ae43b03ad59e864a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 7 Jan 2022 12:44:56 +0200 Subject: [PATCH] Derive some more traits for the public types where it makes sense This makes them easier to use. --- src/playlist.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/playlist.rs b/src/playlist.rs index 5e02161..0706714 100644 --- a/src/playlist.rs +++ b/src/playlist.rs @@ -68,7 +68,7 @@ impl Playlist { /// A [Master Playlist](https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-4.3.4) /// provides a set of Variant Streams, each of which /// describes a different version of the same content. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct MasterPlaylist { pub version: usize, pub variants: Vec, @@ -129,7 +129,7 @@ impl MasterPlaylist { /// Clients should switch between different Variant Streams to adapt to /// network conditions. Clients should choose Renditions based on user /// preferences. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct VariantStream { pub is_i_frame: bool, pub uri: String, @@ -201,7 +201,7 @@ impl VariantStream { /// Media Playlists that contain English, French and Spanish Renditions /// of the same presentation. Or two EXT-X-MEDIA tags can be used to /// identify video-only Media Playlists that show two different camera angles. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct AlternativeMedia { // pub media_type: AlternativeMediaType, @@ -263,7 +263,7 @@ impl AlternativeMedia { } } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone)] pub enum AlternativeMediaType { Audio, Video, @@ -313,7 +313,7 @@ impl fmt::Display for AlternativeMediaType { /// The EXT-X-SESSION-KEY tag allows encryption keys from Media Playlists /// to be specified in a Master Playlist. This allows the client to /// preload these keys without having to read the Media Playlist(s) first. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct SessionKey(pub Key); impl SessionKey { @@ -324,7 +324,7 @@ impl SessionKey { } } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum SessionDataField { Value(String), Uri(String), @@ -333,7 +333,7 @@ pub enum SessionDataField { /// [`#EXT-X-SESSION-DATA:`](https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-4.3.4.4) /// The EXT-X-SESSION-DATA tag allows arbitrary session data to be carried /// in a Master Playlist. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct SessionData { pub data_id: String, pub field: SessionDataField, @@ -456,7 +456,7 @@ impl MediaPlaylist { } /// [`#EXT-X-PLAYLIST-TYPE:`](https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-4.3.3.5) -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone)] pub enum MediaPlaylistType { Event, Vod, @@ -576,7 +576,7 @@ impl MediaSegment { /// KEYFORMAT attribute (or the end of the Playlist file). Two or more /// EXT-X-KEY tags with different KEYFORMAT attributes MAY apply to the /// same Media Segment if they ultimately produce the same decryption key. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct Key { pub method: String, pub uri: Option, @@ -613,7 +613,7 @@ impl Key { /// It applies to every Media Segment that appears after it in the /// Playlist until the next EXT-X-MAP tag or until the end of the /// playlist. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct Map { pub uri: String, pub byte_range: Option, @@ -635,7 +635,7 @@ impl Map { /// The EXT-X-BYTERANGE tag indicates that a Media Segment is a sub-range /// of the resource identified by its URI. It applies only to the next /// URI line that follows it in the Playlist. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct ByteRange { pub length: i32, pub offset: Option, @@ -656,7 +656,7 @@ impl ByteRange { /// The EXT-X-DATERANGE tag associates a Date Range (i.e. a range of time /// defined by a starting and ending date) with a set of attribute / /// value pairs. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct DateRange { pub id: String, pub class: Option, @@ -677,7 +677,7 @@ pub struct DateRange { /// The EXT-X-START tag indicates a preferred point at which to start /// playing a Playlist. By default, clients SHOULD start playback at /// this point when beginning a playback session. -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct Start { pub time_offset: String, pub precise: Option, @@ -699,7 +699,7 @@ impl Start { } /// A simple `#EXT-` tag -#[derive(Debug, Default, PartialEq, Clone)] +#[derive(Debug, Default, PartialEq, Eq, Clone)] pub struct ExtTag { pub tag: String, pub rest: Option,