#[repr(u16)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum SignalType {
Join = 100,
Leave = 101,
RoleChange = 102,
Mute = 200,
Unmute = 201,
StreamStart = 300,
StreamStop = 301,
CodecUpdate = 400,
}
impl TryFrom<u32> for SignalType {
type Error = u32;
fn try_from(v: u32) -> Result<Self, u32> {
use SignalType::*;
Ok(match v {
100 => Join,
101 => Leave,
102 => RoleChange,
200 => Mute,
201 => Unmute,
300 => StreamStart,
301 => StreamStop,
400 => CodecUpdate,
other => return Err(other),
})
}
}
impl SignalType {
pub fn name(self) -> &'static str {
use SignalType::*;
match self {
Join => "JOIN",
Leave => "LEAVE",
RoleChange => "ROLE_CHANGE",
Mute => "MUTE",
Unmute => "UNMUTE",
StreamStart => "STREAM_START",
StreamStop => "STREAM_STOP",
CodecUpdate => "CODEC_UPDATE",
}
}
}