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) 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,
endpoint_config: EndpointConfig::new(),
}
}
#[inline]
pub const fn ipv4(&self) -> bool {
self.ipv4
}
#[inline]
pub const fn ipv6(&self) -> bool {
self.ipv6
}
#[inline]
pub const fn interface_index(&self) -> Option<u32> {
self.interface_index
}
#[inline]
pub const fn max_payload_size(&self) -> usize {
self.max_payload_size
}
#[inline]
pub const fn max_recv_packet_size(&self) -> usize {
self.max_recv_packet_size
}
#[inline]
pub const fn endpoint_config(&self) -> &EndpointConfig {
&self.endpoint_config
}
#[inline]
#[must_use]
pub const fn with_ipv4(mut self, enable: bool) -> Self {
self.ipv4 = enable;
self
}
#[inline]
#[must_use]
pub const fn with_ipv6(mut self, enable: bool) -> Self {
self.ipv6 = enable;
self
}
#[inline]
#[must_use]
pub const fn with_interface_index(mut self, idx: Option<u32>) -> Self {
self.interface_index = idx;
self
}
#[inline]
#[must_use]
pub const fn with_max_payload_size(mut self, size: usize) -> Self {
self.max_payload_size = size;
self
}
#[inline]
#[must_use]
pub const fn with_max_recv_packet_size(mut self, size: usize) -> Self {
self.max_recv_packet_size = size;
self
}
#[inline]
#[must_use]
pub fn with_endpoint_config(mut self, cfg: EndpointConfig) -> Self {
self.endpoint_config = cfg;
self
}
}
#[cfg(test)]
mod tests;