is_rotation_due

Function is_rotation_due 

Source
pub fn is_rotation_due(
    rotate_at: Option<DateTime<Utc>>,
    now: DateTime<Utc>,
) -> bool
Expand description

Check if RNDC key rotation is due based on the rotation timestamp.

Rotation is due if:

  • rotate_at is Some AND
  • rotate_at is less than or equal to now

§Arguments

  • rotate_at - Optional timestamp when rotation should occur (None = no rotation)
  • now - Current timestamp

§Returns

  • true if rotation is due (rotate_at has passed)
  • false if rotation is not due or disabled (rotate_at is None)

§Examples

use bindy::bind9::rndc::is_rotation_due;
use chrono::Utc;

let past_time = Utc::now() - chrono::Duration::hours(1);
let now = Utc::now();

assert!(is_rotation_due(Some(past_time), now)); // Rotation is due

let future_time = Utc::now() + chrono::Duration::hours(1);
assert!(!is_rotation_due(Some(future_time), now)); // Not due yet

assert!(!is_rotation_due(None, now)); // Rotation disabled