should_update_record

Function should_update_record 

Source
pub async fn should_update_record<F>(
    zone_name: &str,
    name: &str,
    record_type: RecordType,
    record_type_name: &str,
    server: &str,
    compare_fn: F,
) -> Result<bool>
where F: FnOnce(&[Record]) -> bool,
Expand description

Helper for declarative record reconciliation.

Implements the observe → diff → act pattern for DNS records:

  1. Query existing record
  2. Compare with desired state using provided callback
  3. Skip if already correct, otherwise proceed with update

§Arguments

  • zone_name - The DNS zone name
  • name - The record name
  • record_type - The DNS record type
  • record_type_name - Human-readable name (e.g., “A”, “AAAA”)
  • server - The DNS server address
  • compare_fn - Callback to compare existing records with desired state

§Returns

Returns Ok(true) if update is needed, Ok(false) if record already matches.

§Errors

Returns an error only if the query fails critically.