1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-05-18 16:28:20 +00:00

Infallible errors

https://doc.rust-lang.org/std/convert/enum.Infallible.html
This commit is contained in:
Luro02 2019-10-05 13:15:42 +02:00
parent f76b223482
commit 99493446eb
4 changed files with 15 additions and 5 deletions

View file

@ -210,3 +210,13 @@ impl From<::strum::ParseError> for Error {
Error::custom(value) // TODO!
}
}
impl From<String> for Error {
fn from(value: String) -> Self { Error::custom(value) }
}
impl From<::core::convert::Infallible> for Error {
fn from(_: ::core::convert::Infallible) -> Self {
Error::custom("An Infallible error has been returned! (this should never happen!)")
}
}

View file

@ -17,7 +17,6 @@ use crate::{Error, RequiredVersion};
#[builder(setter(into, strip_option))]
/// Master playlist.
pub struct MasterPlaylist {
//#[builder(default, setter(name = "version"))]
#[builder(default, setter(skip))]
version_tag: ExtXVersion,
#[builder(default)]

View file

@ -1,8 +1,8 @@
use core::convert::Infallible;
use std::fmt;
use std::str::FromStr;
use crate::utils::{quote, unquote};
use crate::Error;
/// The identifier of a closed captions group or its absence.
///
@ -26,7 +26,7 @@ impl fmt::Display for ClosedCaptions {
}
impl FromStr for ClosedCaptions {
type Err = Error;
type Err = Infallible;
fn from_str(input: &str) -> Result<Self, Self::Err> {
if input.trim() == "NONE" {

View file

@ -1,10 +1,11 @@
use std::convert::Infallible;
use std::fmt;
use std::ops::{Deref, DerefMut};
use std::str::FromStr;
use crate::types::ProtocolVersion;
use crate::utils::{quote, unquote};
use crate::{Error, RequiredVersion};
use crate::RequiredVersion;
/// A list of [usize], that can be used to indicate which version(s)
/// this instance complies with, if more than one version of a particular
@ -51,7 +52,7 @@ impl RequiredVersion for KeyFormatVersions {
}
impl FromStr for KeyFormatVersions {
type Err = Error;
type Err = Infallible;
fn from_str(input: &str) -> Result<Self, Self::Err> {
let mut result = unquote(input)