pub struct RuleStore { /* private fields */ }Expand description
Concurrent, lock-free access to the InnerRuleStore.
Reads are fully lock-free — they clone an Arc (~10ns) and read
from an immutable snapshot. Writers clone the current store, apply
the mutation, and swap atomically via ArcSwap::rcu.
This is the correct abstraction for SideDNS because reads (DNS server, HTTP proxy, WebSocket proxy) vastly outnumber writes (IPC add/remove).
§Cloning
RuleStore wraps an Arc internally — cloning it is cheap and
shares the same underlying data. All clones see writes immediately.
Implementations§
Source§impl RuleStore
impl RuleStore
pub fn new() -> Self
Sourcepub fn resolve(&self, domain: &str) -> Option<DnsRule>
pub fn resolve(&self, domain: &str) -> Option<DnsRule>
Resolve a domain to its matching rule.
Lock-free. Safe to call from hot paths (DNS, proxy).
Sourcepub fn add_ephemeral(&self, rule: DnsRule) -> DnsRule
pub fn add_ephemeral(&self, rule: DnsRule) -> DnsRule
Add or replace an ephemeral rule.
Sourcepub fn remove(&self, domain: &str) -> Option<DnsRule>
pub fn remove(&self, domain: &str) -> Option<DnsRule>
Remove the persistent rule for domain.
Returns true if a rule was removed.
Sourcepub fn remove_ephemeral(&self, domain: &str) -> Option<DnsRule>
pub fn remove_ephemeral(&self, domain: &str) -> Option<DnsRule>
Remove the ephemeral rule for domain.
Returns true if a rule was removed.
Sourcepub fn snapshot_persistent(&self) -> Vec<DnsRule>
pub fn snapshot_persistent(&self) -> Vec<DnsRule>
Return a snapshot of all persistent rules.
Snapshot is consistent but may be stale by the time you use it. Only use for persistence (confy) and IPC list responses.
Sourcepub fn snapshot_all(&self) -> Vec<DnsRule>
pub fn snapshot_all(&self) -> Vec<DnsRule>
Return a snapshot of all rules (ephemeral + persistent).