pub(crate) struct TxtRecords(pub(crate) Mutex<BTreeMap<String, BTreeSet<String>>>);Expand description
Shared multi-value TXT bookkeeping.
A second, third or fourth value at one name is the entire point (see
DnsProvider::publish_txt), so nothing here refuses a write. A
BTreeSet inside a BTreeMap because DnsProvider::txt_values
promises sorted output and a sorted container gives it for free.
Tuple Fields§
§0: Mutex<BTreeMap<String, BTreeSet<String>>>Implementations§
Source§impl TxtRecords
impl TxtRecords
Sourcepub(crate) fn map(&self) -> MutexGuard<'_, BTreeMap<String, BTreeSet<String>>>
pub(crate) fn map(&self) -> MutexGuard<'_, BTreeMap<String, BTreeSet<String>>>
Takes the lock, recovering from a poisoned mutex.
A panic while holding this lock cannot leave the map inconsistent — every write under it is a single map operation — so the data is still good and refusing to serve it would turn one unrelated panic into a permanently broken provider.
Sourcepub(crate) fn insert(&self, host: &str, value: &str) -> bool
pub(crate) fn insert(&self, host: &str, value: &str) -> bool
Adds value at host. Returns whether it was newly added, so a
caller can skip a redundant network write on a retried publish.
Sourcepub(crate) fn remove(&self, host: &str, value: &str) -> Result<(), DnsError>
pub(crate) fn remove(&self, host: &str, value: &str) -> Result<(), DnsError>
Removes value at host. Cleans up the name entirely once its last
value is gone, so an empty set never lingers as a false positive in
Self::values.