use core::fmt;
use std::error::Error;
#[cfg(feature = "cpal")]
pub mod cpal;
#[cfg(feature = "sdl2")]
pub mod sdl2;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AudioHandleErrorKind {
AudioSubsystem,
AudioStream,
InvalidArguments,
}
#[derive(Debug, Clone)]
pub struct AudioHandleError {
description: String,
kind: AudioHandleErrorKind
}
impl fmt::Display for AudioHandleError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.description.fmt(f)
}
}
impl Error for AudioHandleError {}
impl AudioHandleError {
pub fn kind(&self) -> AudioHandleErrorKind {
self.kind
}
}
impl From<(String, AudioHandleErrorKind)> for AudioHandleError {
fn from((description, kind): (String, AudioHandleErrorKind)) -> Self {
AudioHandleError { description, kind }
}
}