use mdns_proto::EndpointConfig;
#[derive(Debug, Clone)]
pub struct ServerOptions {
pub(crate) ipv4: bool,
pub(crate) ipv6: bool,
pub(crate) interface_index: Option<u32>,
pub(crate) max_payload_size: usize,
pub(crate) max_recv_packet_size: usize,
pub(crate) update_channel_capacity: usize,
pub(crate) endpoint_config: EndpointConfig,
}
impl Default for ServerOptions {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl ServerOptions {
#[inline]
pub fn new() -> Self {
Self {
ipv4: true,
ipv6: true,
interface_index: None,
max_payload_size: 1500,
max_recv_packet_size: 9000,
update_channel_capacity: 64,
endpoint_config: EndpointConfig::new(),
}
}
#[inline]
pub const fn ipv4(&self) -> bool {
self.ipv4
}
#[inline]
pub fn with_ipv4(mut self, enable: bool) -> Self {
self.ipv4 = enable;
self
}
#[inline]
pub const fn ipv6(&self) -> bool {
self.ipv6
}
#[inline]
pub fn with_ipv6(mut self, enable: bool) -> Self {
self.ipv6 = enable;
self
}
#[inline]
pub const fn interface_index(&self) -> Option<u32> {
self.interface_index
}
#[inline]
pub fn with_interface_index(mut self, idx: Option<u32>) -> Self {
self.interface_index = idx;
self
}
#[inline]
pub const fn max_payload_size(&self) -> usize {
self.max_payload_size
}
#[inline]
pub fn with_max_payload_size(mut self, size: usize) -> Self {
self.max_payload_size = size;
self
}
#[inline]
pub const fn max_recv_packet_size(&self) -> usize {
self.max_recv_packet_size
}
#[inline]
pub fn with_max_recv_packet_size(mut self, size: usize) -> Self {
self.max_recv_packet_size = size;
self
}
#[inline]
#[deprecated(note = "per-handle channels are unbounded; this setting has no effect")]
pub const fn update_channel_capacity(&self) -> usize {
self.update_channel_capacity
}
#[inline]
#[deprecated(note = "per-handle channels are unbounded; this setting has no effect")]
pub fn with_update_channel_capacity(mut self, cap: usize) -> Self {
self.update_channel_capacity = cap;
self
}
#[inline]
pub const fn endpoint_config(&self) -> &EndpointConfig {
&self.endpoint_config
}
#[inline]
pub fn with_endpoint_config(mut self, cfg: EndpointConfig) -> Self {
self.endpoint_config = cfg;
self
}
}
#[cfg(test)]
#[allow(deprecated)]
mod tests;