Implement Display and Error traits for PlayError

This commit is contained in:
Rekai Musuka 2020-10-08 17:59:16 -05:00
parent 566e979203
commit 5907affb44

View file

@ -85,6 +85,24 @@ impl From<decoder::DecoderError> for PlayError {
}
}
impl fmt::Display for PlayError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::DecoderError(e) => e.fmt(f),
Self::NoDevice => write!(f, "NoDevice"),
}
}
}
impl error::Error for PlayError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Self::DecoderError(e) => Some(e),
Self::NoDevice => None,
}
}
}
#[derive(Debug)]
pub enum StreamError {
PlayStreamError(cpal::PlayStreamError),