1use core::num::NonZeroU32;
2use std::net::SocketAddr;
3
4#[derive(Debug, Clone, Default)]
6pub struct Config {
7 is_ipv6: bool,
8 pub bind: Option<SocketAddr>,
9 pub interface_index: Option<NonZeroU32>,
10 pub ttl: Option<u32>,
11 pub fib: Option<u32>,
12}
13
14impl Config {
15 pub fn new() -> Self {
16 Self::default()
17 }
18
19 pub fn with_ipv6() -> Self {
20 Self {
21 is_ipv6: true,
22 ..Default::default()
23 }
24 }
25
26 pub fn is_ipv6(&self) -> bool {
27 self.bind.map(|x| x.is_ipv6()).unwrap_or(self.is_ipv6)
28 }
29}
30
31impl Config {
32 pub fn bind(mut self, bind: SocketAddr) -> Self {
33 self.bind = Some(bind);
34 self
35 }
36
37 pub fn interface_index(mut self, interface_index: NonZeroU32) -> Self {
38 self.interface_index = Some(interface_index);
39 self
40 }
41
42 pub fn ttl(mut self, ttl: u32) -> Self {
43 self.ttl = Some(ttl);
44 self
45 }
46
47 pub fn fib(mut self, fib: u32) -> Self {
48 self.fib = Some(fib);
49 self
50 }
51}