servo_media_webrtc/
datachannel.rs1use uuid::Uuid;
6
7use crate::WebRtcError;
8
9pub type DataChannelId = usize;
10
11#[derive(Debug)]
12pub enum DataChannelMessage {
13 Text(String),
14 Binary(Vec<u8>),
15}
16
17#[derive(Debug)]
18pub enum DataChannelState {
19 Connecting,
20 Open,
21 Closing,
22 Closed,
23 __Unknown(i32),
24}
25
26pub enum DataChannelEvent {
27 NewChannel,
28 Open,
29 Close,
30 Error(WebRtcError),
31 OnMessage(DataChannelMessage),
32 StateChange(DataChannelState),
33}
34
35pub struct DataChannelInit {
38 pub label: String,
39 pub ordered: bool,
40 pub max_packet_life_time: Option<u16>,
41 pub max_retransmits: Option<u16>,
42 pub protocol: String,
43 pub negotiated: bool,
44 pub id: Option<u16>,
45}
46
47impl Default for DataChannelInit {
48 fn default() -> DataChannelInit {
49 DataChannelInit {
50 label: Uuid::new_v4().to_string(),
51 ordered: true,
52 max_packet_life_time: None,
53 max_retransmits: None,
54 protocol: String::new(),
55 negotiated: false,
56 id: None,
57 }
58 }
59}