use std::error::Error;
use std::fmt;
pub const ERROR_DOMAIN: &str = "MPErrorDomain";
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(i32)]
pub enum ErrorCode {
Unknown = 0,
PermissionDenied = 1,
CloudServiceCapabilityMissing = 2,
NetworkConnectionFailed = 3,
NotFound = 4,
NotSupported = 5,
Cancelled = 6,
RequestTimedOut = 7,
}
impl ErrorCode {
#[must_use]
pub const fn from_raw(raw: i32) -> Self {
match raw {
1 => Self::PermissionDenied,
2 => Self::CloudServiceCapabilityMissing,
3 => Self::NetworkConnectionFailed,
4 => Self::NotFound,
5 => Self::NotSupported,
6 => Self::Cancelled,
7 => Self::RequestTimedOut,
_ => Self::Unknown,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MediaPlayerError {
InvalidArgument(String),
Framework(String),
NotAvailable(String),
Unknown(String),
}
impl fmt::Display for MediaPlayerError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidArgument(message)
| Self::Framework(message)
| Self::NotAvailable(message)
| Self::Unknown(message) => f.write_str(message),
}
}
}
impl Error for MediaPlayerError {}