dnslib/core/dns/cache.rs
1use serde_json::Value;
2
3use crate::core::{
4 dns::service::{CacheRead, CacheWrite},
5 error::Result,
6};
7
8/// List DNS cache entries for a domain through a vendor-neutral cache reader.
9///
10/// # Errors
11///
12/// Returns any error reported by the selected DNS backend.
13pub async fn list_cache<C: CacheRead + ?Sized>(client: &C, domain: &str) -> Result<Value> {
14 client.list_cache(domain).await
15}
16
17/// Delete cached DNS entries for a domain through a vendor-neutral cache writer.
18///
19/// # Errors
20///
21/// Returns any error reported by the selected DNS backend.
22pub async fn delete_cache_zone<C: CacheWrite + ?Sized>(client: &C, domain: &str) -> Result<Value> {
23 client.delete_cache_zone(domain).await
24}
25
26/// Flush the entire DNS cache through a vendor-neutral cache writer.
27///
28/// # Errors
29///
30/// Returns any error reported by the selected DNS backend.
31pub async fn flush_cache<C: CacheWrite + ?Sized>(client: &C) -> Result<Value> {
32 client.flush_cache().await
33}