(cache: &Cache, response: Vec<u8>)
| 15 | |
| 16 | impl CachedResponse { |
| 17 | pub fn new(cache: &Cache, response: Vec<u8>) -> Self { |
| 18 | let ttl = dns::min_ttl(&response, cache.ttl_min, cache.ttl_max, cache.ttl_error) |
| 19 | .unwrap_or(cache.ttl_error); |
| 20 | let expiry = Instant::recent() + Duration::from_secs(u64::from(ttl)); |
| 21 | CachedResponse { |
| 22 | response, |
| 23 | expiry, |
| 24 | original_ttl: ttl, |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | #[inline] |
| 29 | pub fn set_tid(&mut self, tid: u16) { |