pub fn diff(
old: &[AdapterSnapshot],
new: &[AdapterSnapshot],
timestamp: SystemTime,
) -> Vec<IpChange>Expand description
Compares two adapter snapshots and returns a list of IP changes.
This is a pure function that detects which IP addresses were added or removed between two points in time. The comparison is done per-adapter by name.
§Arguments
old- The previous state of network adaptersnew- The current state of network adapterstimestamp- The timestamp to assign to all detected changes
§Returns
A vector of IpChange events. The order is not guaranteed.
§Algorithm
For each adapter (matched by name):
- Find addresses in
newbut not inold→Added - Find addresses in
oldbut not innew→Removed
Adapters that exist only in old have all their addresses marked as Removed.
Adapters that exist only in new have all their addresses marked as Added.