1use std::fmt::Display;
19
20use livekit_protocol as proto;
21
22mod enum_dispatch;
23
24pub const CLIENT_PROTOCOL_DEFAULT: i32 = 0;
30
31pub const CLIENT_PROTOCOL_DATA_STREAM_RPC: i32 = 1;
33
34#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
39pub struct ParticipantIdentity(pub String);
40
41impl From<String> for ParticipantIdentity {
42 fn from(value: String) -> Self {
43 Self(value)
44 }
45}
46
47impl From<&str> for ParticipantIdentity {
48 fn from(value: &str) -> Self {
49 Self(value.to_string())
50 }
51}
52
53impl From<ParticipantIdentity> for String {
54 fn from(value: ParticipantIdentity) -> Self {
55 value.0
56 }
57}
58
59impl Display for ParticipantIdentity {
60 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
61 write!(f, "{}", self.0)
62 }
63}
64
65impl ParticipantIdentity {
66 pub fn as_str(&self) -> &str {
67 &self.0
68 }
69}
70
71#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
76pub enum EncryptionType {
77 #[default]
78 None,
79 Gcm,
80 Custom,
81}
82
83impl From<proto::encryption::Type> for EncryptionType {
84 fn from(value: proto::encryption::Type) -> Self {
85 match value {
86 proto::encryption::Type::None => Self::None,
87 proto::encryption::Type::Gcm => Self::Gcm,
88 proto::encryption::Type::Custom => Self::Custom,
89 }
90 }
91}
92
93impl From<EncryptionType> for proto::encryption::Type {
94 fn from(value: EncryptionType) -> Self {
95 match value {
96 EncryptionType::None => Self::None,
97 EncryptionType::Gcm => Self::Gcm,
98 EncryptionType::Custom => Self::Custom,
99 }
100 }
101}
102
103impl From<EncryptionType> for i32 {
104 fn from(value: EncryptionType) -> Self {
105 match value {
106 EncryptionType::None => 0,
107 EncryptionType::Gcm => 1,
108 EncryptionType::Custom => 2,
109 }
110 }
111}