Implement backups, commit and restoration

This commit is contained in:
2026-10-20 00:13:39 +03:00
parent c879a8101b
commit 5418841b92
17 changed files with 5049 additions and 38 deletions
+21
View File
@@ -211,6 +211,25 @@ impl ClientStates {
&self.reserved_addresses
}
/// Restore conservative reservations from saved metadata without asserting
/// that the running interface matches the saved snapshot.
pub fn restore_persisted_reservations(
&mut self,
reservations: impl IntoIterator<Item = IpAddr>,
) -> Result<(), DomainError> {
let reservations = reservations.into_iter().collect::<BTreeSet<_>>();
if reservations
.iter()
.any(|address| self.saved.addresses().any(|saved| saved == *address))
{
return Err(DomainError::ReservationConflictsWithSavedClient);
}
self.reserved_addresses = reservations;
self.applied_snapshot = None;
self.applied = RuntimeObservation::Unknown;
Ok(())
}
pub fn draft_mut(&mut self) -> &mut Snapshot {
&mut self.draft
}
@@ -297,6 +316,8 @@ pub enum DomainError {
AddressUnavailable,
#[error("verified applied clients do not match the saved snapshot")]
AppliedSnapshotMismatch,
#[error("persisted reservation conflicts with a saved client address")]
ReservationConflictsWithSavedClient,
}
/// Return the lowest available host in `range` without walking the subnet.