1#[repr(u16)]
6#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
7pub enum SignalType {
8 Join = 100,
10 Leave = 101,
12 RoleChange = 102,
14 Mute = 200,
16 Unmute = 201,
18 StreamStart = 300,
20 StreamStop = 301,
22 CodecUpdate = 400,
24}
25
26impl TryFrom<u32> for SignalType {
27 type Error = u32;
28 fn try_from(v: u32) -> Result<Self, u32> {
29 use SignalType::*;
30 Ok(match v {
31 100 => Join,
32 101 => Leave,
33 102 => RoleChange,
34 200 => Mute,
35 201 => Unmute,
36 300 => StreamStart,
37 301 => StreamStop,
38 400 => CodecUpdate,
39 other => return Err(other),
40 })
41 }
42}
43
44impl SignalType {
45 pub fn name(self) -> &'static str {
47 use SignalType::*;
48 match self {
49 Join => "JOIN",
50 Leave => "LEAVE",
51 RoleChange => "ROLE_CHANGE",
52 Mute => "MUTE",
53 Unmute => "UNMUTE",
54 StreamStart => "STREAM_START",
55 StreamStop => "STREAM_STOP",
56 CodecUpdate => "CODEC_UPDATE",
57 }
58 }
59}