srt_protocol/options/
bind.rs1use super::*;
2
3#[derive(Debug, Clone, Eq, PartialEq)]
4pub enum BindOptions {
5 Listen(Valid<ListenerOptions>),
6 Call(Valid<CallerOptions>),
7 Rendezvous(Valid<RendezvousOptions>),
8}
9
10impl From<Valid<ListenerOptions>> for BindOptions {
11 fn from(options: Valid<ListenerOptions>) -> Self {
12 BindOptions::Listen(options)
13 }
14}
15
16impl From<Valid<CallerOptions>> for BindOptions {
17 fn from(options: Valid<CallerOptions>) -> Self {
18 BindOptions::Call(options)
19 }
20}
21
22impl From<Valid<RendezvousOptions>> for BindOptions {
23 fn from(options: Valid<RendezvousOptions>) -> Self {
24 BindOptions::Rendezvous(options)
25 }
26}
27
28#[cfg(test)]
29mod tests {
30 use super::*;
31
32 #[test]
33 fn into() {
34 let caller = CallerOptions::new("127.0.0.1:42", Some("stream ID"))
35 .unwrap()
36 .with(Connect::default())
37 .unwrap()
38 .with(Session::default())
39 .unwrap()
40 .with(Encryption::default())
41 .unwrap()
42 .with(Sender::default())
43 .unwrap()
44 .with(Receiver::default())
45 .unwrap();
46
47 let listener = ListenerOptions::new(":42")
48 .unwrap()
49 .with(Connect::default())
50 .unwrap()
51 .with(Session::default())
52 .unwrap()
53 .with3(
54 Encryption::default(),
55 Sender::default(),
56 Receiver::default(),
57 )
58 .unwrap();
59
60 let rendezvous = RendezvousOptions::new("127.0.0.1:42")
61 .unwrap()
62 .with(Connect::default())
63 .unwrap()
64 .with(Session::default())
65 .unwrap()
66 .with(Encryption::default())
67 .unwrap()
68 .with2(Sender::default(), Receiver::default())
69 .unwrap();
70
71 let _: BindOptions = caller.into();
72 let _: BindOptions = listener.into();
73 let _: BindOptions = rendezvous.into();
74 }
75}