use alloc::string::String;
use thiserror::Error;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Error, PartialEq, Clone)]
#[non_exhaustive]
pub enum Error {
#[error("hls parse (line {line_no}): {reason}\n {line}")]
HlsParse {
line_no: usize,
line: String,
reason: String,
},
#[error("attribute value {value:?} is not valid as {kind}")]
InvalidAttrValue {
value: String,
kind: &'static str,
},
#[error("{0} is not a finite, non-negative decimal-floating-point number of seconds")]
InvalidDecimalSeconds(f64),
#[error("{0} is not a finite decimal-floating-point number of seconds")]
InvalidSignedDecimalSeconds(f64),
#[error("{what} {value:?} contains {bad_char:?}, forbidden in an HLS quoted-string")]
InvalidQuotedString {
what: String,
bad_char: char,
value: String,
},
#[error("URI {value:?} ({what}) contains {bad_char:?}, forbidden in an HLS URI")]
InvalidUri {
what: String,
bad_char: char,
value: String,
},
#[error("EXT-X-KEY with METHOD={method} has no URI")]
KeyWithoutUri {
method: crate::EncryptionMethod,
},
#[error("no identity key applies; unsupported KEYFORMAT {keyformat:?}")]
UnsupportedKeyFormat {
keyformat: String,
},
#[error("invalid CLOSED-CAPTIONS INSTREAM-ID {value:?}")]
InvalidInstreamId {
value: String,
},
#[error("INSTREAM-ID {value:?} is not valid on TYPE={media_type}")]
InstreamIdTypeMismatch {
media_type: crate::MediaType,
value: String,
},
#[error("group {group_id:?} of TYPE={media_type} has more than one DEFAULT=YES member")]
DuplicateDefaultInGroup {
media_type: crate::MediaType,
group_id: String,
},
#[error("group {group_id:?} of TYPE={media_type} has more than one member named {name:?}")]
DuplicateNameInGroup {
media_type: crate::MediaType,
group_id: String,
name: String,
},
#[error("attribute {attribute} must be exactly YES or NO, got {value:?}")]
InvalidYesNo {
attribute: &'static str,
value: String,
},
#[error("IV {value:?} is not a 0x-prefixed 128-bit hexadecimal-sequence")]
InvalidIv {
value: String,
},
#[error("unterminated quoted-string in attribute list {list:?}")]
UnterminatedQuotedString {
list: String,
},
#[error("duplicate attribute {name:?}")]
DuplicateAttribute {
name: String,
},
}