use core::num::ParseIntError;
use derive_more::{IsVariant, TryUnwrap, Unwrap};
#[derive(Debug, Clone, PartialEq, Eq, IsVariant, Unwrap, TryUnwrap, thiserror::Error)]
#[unwrap(ref, ref_mut)]
#[try_unwrap(ref, ref_mut)]
pub enum ParseMinuteError {
#[error("minute component is not zero-padded to 2 digits")]
#[unwrap(ignore)]
#[try_unwrap(ignore)]
NotPadded,
#[error("minute component must be between 0-59, but was {0}")]
Overflow(u8),
#[error(transparent)]
ParseInt(#[from] ParseIntError),
}
#[derive(Debug, Clone, PartialEq, Eq, IsVariant, Unwrap, TryUnwrap, thiserror::Error)]
#[unwrap(ref, ref_mut)]
#[try_unwrap(ref, ref_mut)]
pub enum ParseSecondError {
#[error("second component is not zero-padded to 2 digits")]
#[unwrap(ignore)]
#[try_unwrap(ignore)]
NotPadded,
#[error("second component must be between 0-59, but was {0}")]
Overflow(u8),
#[error(transparent)]
ParseInt(#[from] ParseIntError),
}
#[derive(Debug, Clone, PartialEq, Eq, IsVariant, Unwrap, TryUnwrap, thiserror::Error)]
#[unwrap(ref, ref_mut)]
#[try_unwrap(ref, ref_mut)]
pub enum ParseHourError {
#[error("hour component is not zero-padded to 2 digits or contains invalid characters")]
#[unwrap(ignore)]
#[try_unwrap(ignore)]
NotPadded,
#[error("hour component must be between 0-999, but was {0}")]
Overflow(u16),
#[error("hour component overflowed")]
#[unwrap(ignore)]
#[try_unwrap(ignore)]
HourOverflow,
#[error(transparent)]
ParseInt(#[from] ParseIntError),
}
#[derive(Debug, Clone, PartialEq, Eq, IsVariant, Unwrap, TryUnwrap, thiserror::Error)]
#[unwrap(ref, ref_mut)]
#[try_unwrap(ref, ref_mut)]
pub enum ParseMillisecondError {
#[error("millisecond component is not zero-padded to 3 digits")]
#[unwrap(ignore)]
#[try_unwrap(ignore)]
NotPadded,
#[error("millisecond component must be between 0-999, but was {0}")]
Overflow(u16),
#[error(transparent)]
ParseInt(#[from] ParseIntError),
}
#[derive(Debug, Clone, PartialEq, Eq, IsVariant, Unwrap, TryUnwrap, thiserror::Error)]
#[unwrap(ref, ref_mut)]
#[try_unwrap(ref, ref_mut)]
pub enum ParseCentisecondError {
#[error("centisecond component is not zero-padded to 2 digits")]
#[unwrap(ignore)]
#[try_unwrap(ignore)]
NotPadded,
#[error("centisecond component must be between 0-99, but was {0}")]
Overflow(u8),
#[error(transparent)]
ParseInt(#[from] ParseIntError),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum TimestampError {
#[error("invalid length")]
InvalidLength,
#[error("invalid format")]
InvalidFormat,
#[error("invalid digits")]
InvalidDigits,
}
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, thiserror::Error)]
#[error("cue text nests deeper than the maximum depth of {max_depth}")]
pub struct MaxDepthExceededError {
max_depth: usize,
}
#[cfg(any(feature = "alloc", feature = "std"))]
impl MaxDepthExceededError {
#[cfg_attr(not(tarpaulin), inline(always))]
pub(crate) const fn new(max_depth: usize) -> Self {
Self { max_depth }
}
#[cfg_attr(not(tarpaulin), inline(always))]
pub const fn max_depth(&self) -> usize {
self.max_depth
}
}
#[derive(Debug, Clone, PartialEq, Eq, IsVariant, Unwrap, TryUnwrap, thiserror::Error)]
#[unwrap(ref, ref_mut)]
#[try_unwrap(ref, ref_mut)]
pub enum ParseIndexNumberError {
#[error("index number cannot be zero")]
Zero,
#[error("index number must be between 1-18446744073709551615")]
Overflow,
#[error(transparent)]
ParseInt(#[from] ParseIntError),
}