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

minor protocol_version fixes

This commit is contained in:
Luro02 2019-09-17 15:40:10 +02:00
parent e55113e752
commit 612c3d15be
4 changed files with 12 additions and 2 deletions

View file

@ -158,7 +158,7 @@ impl MasterPlaylistBuilder {
.flatten(), .flatten(),
) )
.max() .max()
.unwrap_or(ProtocolVersion::V7) .unwrap_or(ProtocolVersion::latest())
} }
fn validate_stream_inf_tags(&self) -> crate::Result<()> { fn validate_stream_inf_tags(&self) -> crate::Result<()> {

View file

@ -200,7 +200,7 @@ impl MediaPlaylistBuilder {
.unwrap_or(ProtocolVersion::V1) .unwrap_or(ProtocolVersion::V1)
})) }))
.max() .max()
.unwrap_or(ProtocolVersion::V1) .unwrap_or(ProtocolVersion::latest())
} }
/// Adds a media segment to the resulting playlist. /// Adds a media segment to the resulting playlist.

View file

@ -13,6 +13,7 @@ use crate::Error;
pub struct InitializationVector(pub [u8; 16]); pub struct InitializationVector(pub [u8; 16]);
impl InitializationVector { impl InitializationVector {
/// Converts the initialization vector to a slice.
pub const fn to_slice(&self) -> [u8; 16] { pub const fn to_slice(&self) -> [u8; 16] {
self.0 self.0
} }

View file

@ -17,6 +17,14 @@ pub enum ProtocolVersion {
V6, V6,
V7, V7,
} }
impl ProtocolVersion {
/// Returns the newest ProtocolVersion, that is supported by this library.
pub const fn latest() -> Self {
Self::V7
}
}
impl fmt::Display for ProtocolVersion { impl fmt::Display for ProtocolVersion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let n = { let n = {
@ -33,6 +41,7 @@ impl fmt::Display for ProtocolVersion {
write!(f, "{}", n) write!(f, "{}", n)
} }
} }
impl FromStr for ProtocolVersion { impl FromStr for ProtocolVersion {
type Err = Error; type Err = Error;