mirror of
https://github.com/sile/hls_m3u8.git
synced 2025-01-10 20:25:25 +00:00
Infallible errors
https://doc.rust-lang.org/std/convert/enum.Infallible.html
This commit is contained in:
parent
f76b223482
commit
99493446eb
4 changed files with 15 additions and 5 deletions
10
src/error.rs
10
src/error.rs
|
@ -210,3 +210,13 @@ impl From<::strum::ParseError> for Error {
|
||||||
Error::custom(value) // TODO!
|
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!)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ use crate::{Error, RequiredVersion};
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
/// Master playlist.
|
/// Master playlist.
|
||||||
pub struct MasterPlaylist {
|
pub struct MasterPlaylist {
|
||||||
//#[builder(default, setter(name = "version"))]
|
|
||||||
#[builder(default, setter(skip))]
|
#[builder(default, setter(skip))]
|
||||||
version_tag: ExtXVersion,
|
version_tag: ExtXVersion,
|
||||||
#[builder(default)]
|
#[builder(default)]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
use core::convert::Infallible;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::utils::{quote, unquote};
|
use crate::utils::{quote, unquote};
|
||||||
use crate::Error;
|
|
||||||
|
|
||||||
/// The identifier of a closed captions group or its absence.
|
/// The identifier of a closed captions group or its absence.
|
||||||
///
|
///
|
||||||
|
@ -26,7 +26,7 @@ impl fmt::Display for ClosedCaptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for ClosedCaptions {
|
impl FromStr for ClosedCaptions {
|
||||||
type Err = Error;
|
type Err = Infallible;
|
||||||
|
|
||||||
fn from_str(input: &str) -> Result<Self, Self::Err> {
|
fn from_str(input: &str) -> Result<Self, Self::Err> {
|
||||||
if input.trim() == "NONE" {
|
if input.trim() == "NONE" {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use std::convert::Infallible;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::types::ProtocolVersion;
|
use crate::types::ProtocolVersion;
|
||||||
use crate::utils::{quote, unquote};
|
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)
|
/// 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
|
/// this instance complies with, if more than one version of a particular
|
||||||
|
@ -51,7 +52,7 @@ impl RequiredVersion for KeyFormatVersions {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for KeyFormatVersions {
|
impl FromStr for KeyFormatVersions {
|
||||||
type Err = Error;
|
type Err = Infallible;
|
||||||
|
|
||||||
fn from_str(input: &str) -> Result<Self, Self::Err> {
|
fn from_str(input: &str) -> Result<Self, Self::Err> {
|
||||||
let mut result = unquote(input)
|
let mut result = unquote(input)
|
||||||
|
|
Loading…
Reference in a new issue