armature_security/
dns_prefetch_control.rs

1//! DNS Prefetch Control
2//!
3//! Controls browser DNS prefetching to improve privacy.
4
5/// DNS Prefetch Control options
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum DnsPrefetchControl {
8    /// Disable DNS prefetching
9    Off,
10    /// Enable DNS prefetching
11    On,
12}
13
14impl DnsPrefetchControl {
15    pub fn to_header_value(&self) -> String {
16        match self {
17            Self::Off => "off".to_string(),
18            Self::On => "on".to_string(),
19        }
20    }
21}
22
23#[cfg(test)]
24mod tests {
25    use super::*;
26
27    #[test]
28    fn test_dns_prefetch_control() {
29        assert_eq!(DnsPrefetchControl::Off.to_header_value(), "off");
30        assert_eq!(DnsPrefetchControl::On.to_header_value(), "on");
31    }
32}