use crate::AudexError;
use std::fmt;
#[derive(Debug, Clone)]
pub struct MP4Error {
message: String,
}
impl MP4Error {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
impl fmt::Display for MP4Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.message)
}
}
impl std::error::Error for MP4Error {}
impl From<MP4Error> for AudexError {
fn from(err: MP4Error) -> Self {
AudexError::ParseError(err.message)
}
}
#[derive(Debug, Clone)]
pub struct MP4MetadataError {
message: String,
}
impl MP4MetadataError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
impl fmt::Display for MP4MetadataError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "MP4 Metadata Error: {}", self.message)
}
}
impl std::error::Error for MP4MetadataError {}
impl From<MP4MetadataError> for AudexError {
fn from(err: MP4MetadataError) -> Self {
AudexError::ParseError(err.message)
}
}
impl From<MP4MetadataError> for MP4Error {
fn from(err: MP4MetadataError) -> Self {
MP4Error::new(err.message)
}
}
#[derive(Debug, Clone)]
pub struct MP4StreamInfoError {
message: String,
}
impl MP4StreamInfoError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
impl fmt::Display for MP4StreamInfoError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "MP4 Stream Info Error: {}", self.message)
}
}
impl std::error::Error for MP4StreamInfoError {}
impl From<MP4StreamInfoError> for AudexError {
fn from(err: MP4StreamInfoError) -> Self {
AudexError::ParseError(err.message)
}
}
impl From<MP4StreamInfoError> for MP4Error {
fn from(err: MP4StreamInfoError) -> Self {
MP4Error::new(err.message)
}
}
#[derive(Debug, Clone)]
pub struct MP4NoTrackError {
message: String,
}
impl MP4NoTrackError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
impl fmt::Display for MP4NoTrackError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "MP4 No Track Error: {}", self.message)
}
}
impl std::error::Error for MP4NoTrackError {}
impl From<MP4NoTrackError> for AudexError {
fn from(err: MP4NoTrackError) -> Self {
AudexError::ParseError(err.message)
}
}
impl From<MP4NoTrackError> for MP4StreamInfoError {
fn from(err: MP4NoTrackError) -> Self {
MP4StreamInfoError::new(err.message)
}
}
impl From<MP4NoTrackError> for MP4Error {
fn from(err: MP4NoTrackError) -> Self {
MP4Error::new(err.message)
}
}
#[derive(Debug, Clone)]
pub struct MP4MetadataValueError {
message: String,
}
impl MP4MetadataValueError {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
}
impl fmt::Display for MP4MetadataValueError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "MP4 Metadata Value Error: {}", self.message)
}
}
impl std::error::Error for MP4MetadataValueError {}
impl From<MP4MetadataValueError> for AudexError {
fn from(err: MP4MetadataValueError) -> Self {
AudexError::ParseError(err.message)
}
}
impl From<MP4MetadataValueError> for MP4MetadataError {
fn from(err: MP4MetadataValueError) -> Self {
MP4MetadataError::new(err.message)
}
}
impl From<MP4MetadataValueError> for MP4Error {
fn from(err: MP4MetadataValueError) -> Self {
MP4Error::new(err.message)
}
}
#[derive(Debug, Clone)]
pub struct EasyMP4KeyError {
key: String,
message: String,
}
impl EasyMP4KeyError {
pub fn new(key: impl Into<String>) -> Self {
let key = key.into();
let message = format!("'{}'", key);
Self { key, message }
}
pub fn with_message(key: impl Into<String>, message: impl Into<String>) -> Self {
Self {
key: key.into(),
message: message.into(),
}
}
pub fn key(&self) -> &str {
&self.key
}
}
impl fmt::Display for EasyMP4KeyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.message)
}
}
impl std::error::Error for EasyMP4KeyError {}
impl From<EasyMP4KeyError> for AudexError {
fn from(err: EasyMP4KeyError) -> Self {
AudexError::ParseError(err.message)
}
}
impl From<EasyMP4KeyError> for MP4Error {
fn from(err: EasyMP4KeyError) -> Self {
MP4Error::new(err.message)
}
}