1use mdns_proto::EndpointConfig;
4
5#[derive(Debug, Clone)]
17pub struct ServerOptions {
18 pub(crate) ipv4: bool,
19 pub(crate) ipv6: bool,
20 pub(crate) interface_index: Option<u32>,
21 pub(crate) max_payload_size: usize,
22 pub(crate) max_recv_packet_size: usize,
23 pub(crate) update_channel_capacity: usize,
24 pub(crate) endpoint_config: EndpointConfig,
25}
26
27impl Default for ServerOptions {
28 #[inline]
29 fn default() -> Self {
30 Self::new()
31 }
32}
33
34impl ServerOptions {
35 #[inline]
37 pub fn new() -> Self {
38 Self {
39 ipv4: true,
40 ipv6: true,
41 interface_index: None,
42 max_payload_size: 1500,
43 max_recv_packet_size: 9000,
44 update_channel_capacity: 64,
45 endpoint_config: EndpointConfig::new(),
46 }
47 }
48
49 #[inline]
51 pub const fn ipv4(&self) -> bool {
52 self.ipv4
53 }
54
55 #[inline]
57 pub fn with_ipv4(mut self, enable: bool) -> Self {
58 self.ipv4 = enable;
59 self
60 }
61
62 #[inline]
64 pub const fn ipv6(&self) -> bool {
65 self.ipv6
66 }
67
68 #[inline]
70 pub fn with_ipv6(mut self, enable: bool) -> Self {
71 self.ipv6 = enable;
72 self
73 }
74
75 #[inline]
77 pub const fn interface_index(&self) -> Option<u32> {
78 self.interface_index
79 }
80
81 #[inline]
85 pub fn with_interface_index(mut self, idx: Option<u32>) -> Self {
86 self.interface_index = idx;
87 self
88 }
89
90 #[inline]
93 pub const fn max_payload_size(&self) -> usize {
94 self.max_payload_size
95 }
96
97 #[inline]
99 pub fn with_max_payload_size(mut self, size: usize) -> Self {
100 self.max_payload_size = size;
101 self
102 }
103
104 #[inline]
109 pub const fn max_recv_packet_size(&self) -> usize {
110 self.max_recv_packet_size
111 }
112
113 #[inline]
115 pub fn with_max_recv_packet_size(mut self, size: usize) -> Self {
116 self.max_recv_packet_size = size;
117 self
118 }
119
120 #[inline]
127 #[deprecated(note = "per-handle channels are unbounded; this setting has no effect")]
128 pub const fn update_channel_capacity(&self) -> usize {
129 self.update_channel_capacity
130 }
131
132 #[inline]
135 #[deprecated(note = "per-handle channels are unbounded; this setting has no effect")]
136 pub fn with_update_channel_capacity(mut self, cap: usize) -> Self {
137 self.update_channel_capacity = cap;
138 self
139 }
140
141 #[inline]
143 pub const fn endpoint_config(&self) -> &EndpointConfig {
144 &self.endpoint_config
145 }
146
147 #[inline]
149 pub fn with_endpoint_config(mut self, cfg: EndpointConfig) -> Self {
150 self.endpoint_config = cfg;
151 self
152 }
153}
154
155#[cfg(test)]
156#[allow(deprecated)]
157mod tests;