#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
pub enum SessionErrorCode {
NoError = 0x0,
InternalError = 0x1,
Unauthorized = 0x2,
ProtocolViolation = 0x3,
DuplicateTrackAlias = 0x4,
ParameterLengthMismatch = 0x5,
TooManySubscribes = 0x6,
GoawayTimeout = 0x10,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
pub enum SubscribeErrorCode {
InternalError = 0x0,
InvalidRange = 0x1,
RetryTrackAlias = 0x2,
TrackDoesNotExist = 0x3,
Unauthorized = 0x4,
Timeout = 0x5,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
pub enum SubscribeDoneStatusCode {
Unsubscribed = 0x0,
InternalError = 0x1,
Unauthorized = 0x2,
TrackEnded = 0x3,
SubscriptionEnded = 0x4,
GoingAway = 0x5,
Expired = 0x6,
}
impl SessionErrorCode {
pub const ALL: &[SessionErrorCode] = &[
SessionErrorCode::NoError,
SessionErrorCode::InternalError,
SessionErrorCode::Unauthorized,
SessionErrorCode::ProtocolViolation,
SessionErrorCode::DuplicateTrackAlias,
SessionErrorCode::ParameterLengthMismatch,
SessionErrorCode::TooManySubscribes,
SessionErrorCode::GoawayTimeout,
];
pub fn from_u64(v: u64) -> Option<Self> {
match v {
0x0 => Some(SessionErrorCode::NoError),
0x1 => Some(SessionErrorCode::InternalError),
0x2 => Some(SessionErrorCode::Unauthorized),
0x3 => Some(SessionErrorCode::ProtocolViolation),
0x4 => Some(SessionErrorCode::DuplicateTrackAlias),
0x5 => Some(SessionErrorCode::ParameterLengthMismatch),
0x6 => Some(SessionErrorCode::TooManySubscribes),
0x10 => Some(SessionErrorCode::GoawayTimeout),
_ => None,
}
}
pub fn as_u64(self) -> u64 {
self as u64
}
}
impl SubscribeErrorCode {
pub const ALL: &[SubscribeErrorCode] = &[
SubscribeErrorCode::InternalError,
SubscribeErrorCode::InvalidRange,
SubscribeErrorCode::RetryTrackAlias,
SubscribeErrorCode::TrackDoesNotExist,
SubscribeErrorCode::Unauthorized,
SubscribeErrorCode::Timeout,
];
pub fn from_u64(v: u64) -> Option<Self> {
match v {
0x0 => Some(SubscribeErrorCode::InternalError),
0x1 => Some(SubscribeErrorCode::InvalidRange),
0x2 => Some(SubscribeErrorCode::RetryTrackAlias),
0x3 => Some(SubscribeErrorCode::TrackDoesNotExist),
0x4 => Some(SubscribeErrorCode::Unauthorized),
0x5 => Some(SubscribeErrorCode::Timeout),
_ => None,
}
}
pub fn as_u64(self) -> u64 {
self as u64
}
}
impl SubscribeDoneStatusCode {
pub const ALL: &[SubscribeDoneStatusCode] = &[
SubscribeDoneStatusCode::Unsubscribed,
SubscribeDoneStatusCode::InternalError,
SubscribeDoneStatusCode::Unauthorized,
SubscribeDoneStatusCode::TrackEnded,
SubscribeDoneStatusCode::SubscriptionEnded,
SubscribeDoneStatusCode::GoingAway,
SubscribeDoneStatusCode::Expired,
];
pub fn from_u64(v: u64) -> Option<Self> {
match v {
0x0 => Some(SubscribeDoneStatusCode::Unsubscribed),
0x1 => Some(SubscribeDoneStatusCode::InternalError),
0x2 => Some(SubscribeDoneStatusCode::Unauthorized),
0x3 => Some(SubscribeDoneStatusCode::TrackEnded),
0x4 => Some(SubscribeDoneStatusCode::SubscriptionEnded),
0x5 => Some(SubscribeDoneStatusCode::GoingAway),
0x6 => Some(SubscribeDoneStatusCode::Expired),
_ => None,
}
}
pub fn as_u64(self) -> u64 {
self as u64
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
pub enum TrackStatusCode {
InProgress = 0x00,
TrackDoesNotExist = 0x01,
NotYetBegun = 0x02,
Finished = 0x03,
RelayStatusUnavailable = 0x04,
}
impl TrackStatusCode {
pub fn from_u64(v: u64) -> Option<Self> {
match v {
0x00 => Some(TrackStatusCode::InProgress),
0x01 => Some(TrackStatusCode::TrackDoesNotExist),
0x02 => Some(TrackStatusCode::NotYetBegun),
0x03 => Some(TrackStatusCode::Finished),
0x04 => Some(TrackStatusCode::RelayStatusUnavailable),
_ => None,
}
}
pub fn requires_zero_location(self) -> bool {
matches!(self, TrackStatusCode::TrackDoesNotExist | TrackStatusCode::NotYetBegun)
}
pub fn as_u64(self) -> u64 {
self as u64
}
}