/// Update interface `id` with its new reachability info.
///
/// Returns the protocols and their new reachability states iff a change was observed.
Update interface `id` with its new reachability info.
Returns the protocols and their new reachability states iff a change was observed.
Update interface ` id ` with its new reachability info . Returns the protocols and their new reachability states iff a change was observed .
fn update(&mut self, id: Id, new_reachability: IpVersions<StateEvent>) -> StateDelta {
        let previous_system_ipv4 = self.get_system_ipv4();
        let previous_system_ipv6 = self.get_system_ipv6();
        let port = match self.per_interface.entry(id) {
            Entry::Occupied(mut occupied) => {
                let IpVersions { ipv4, ipv6 } = occupied.get_mut();
                let IpVersions { ipv4: new_ipv4, ipv6: new_ipv6 } = new_reachability;
                IpVersions { ipv4: ipv4.update(new_ipv4), ipv6: ipv6.update(new_ipv6) }
            }
            Entry::Vacant(vacant) => {
                let IpVersions { ipv4, ipv6 } = vacant.insert(new_reachability);
                IpVersions {
                    ipv4: Delta { previous: None, current: *ipv4 },
                    ipv6: Delta { previous: None, current: *ipv6 },
                }
            }
        };
        let IpVersions { ipv4: system_ipv4, ipv6: system_ipv6 } = self.per_interface.iter().fold(
            {
                let IpVersions {
                    ipv4: Delta { previous: _, current: ipv4 },
                    ipv6: Delta { previous: _, current: ipv6 },
                } = port;
                IpVersions {
                    ipv4: SystemState { id, state: ipv4 },
                    ipv6: SystemState { id, state: ipv6 },
                }
            },
            |IpVersions { ipv4: system_ipv4, ipv6: system_ipv6 },
             (&id, &IpVersions { ipv4, ipv6 })| {
                IpVersions {
                    ipv4: system_ipv4.max(SystemState { id, state: ipv4 }),
                    ipv6: system_ipv6.max(SystemState { id, state: ipv6 }),
                }
            },
        );
        self.system = IpVersions { ipv4: Some(system_ipv4.id), ipv6: Some(system_ipv6.id) };
        StateDelta {
            port,
            system: IpVersions {
                ipv4: Delta { previous: previous_system_ipv4, current: system_ipv4 },
                ipv6: Delta { previous: previous_system_ipv6, current: system_ipv6 },
            },
        }
    }
fn update ( & mut self , id : Id , new_reachability : IpVersions < StateEvent > ) -> StateDelta { let previous_system_ipv4 = self . get_system_ipv4 ( ) ; let previous_system_ipv6 = self . get_system_ipv6 ( ) ; let port = match self . per_interface . entry ( id ) { Entry :: Occupied ( mut occupied ) => { let IpVersions { ipv4 , ipv6 } = occupied . get_mut ( ) ; let IpVersions { ipv4 : new_ipv4 , ipv6 : new_ipv6 } = new_reachability ; IpVersions { ipv4 : ipv4 . update ( new_ipv4 ) , ipv6 : ipv6 . update ( new_ipv6 ) } } Entry :: Vacant ( vacant ) => { let IpVersions { ipv4 , ipv6 } = vacant . insert ( new_reachability ) ; IpVersions { ipv4 : Delta { previous : None , current : * ipv4 } , ipv6 : Delta { previous : None , current : * ipv6 } , } } } ; let IpVersions { ipv4 : system_ipv4 , ipv6 : system_ipv6 } = self . per_interface . iter ( ) . fold ( { let IpVersions { ipv4 : Delta { previous : _ , current : ipv4 } , ipv6 : Delta { previous : _ , current : ipv6 } , } = port ; IpVersions { ipv4 : SystemState { id , state : ipv4 } , ipv6 : SystemState { id , state : ipv6 } , } } , | IpVersions { ipv4 : system_ipv4 , ipv6 : system_ipv6 } , ( & id , & IpVersions { ipv4 , ipv6 } ) | { IpVersions { ipv4 : system_ipv4 . max ( SystemState { id , state : ipv4 } ) , ipv6 : system_ipv6 . max ( SystemState { id , state : ipv6 } ) , } } , ) ; self . system = IpVersions { ipv4 : Some ( system_ipv4 . id ) , ipv6 : Some ( system_ipv6 . id ) } ; StateDelta { port , system : IpVersions { ipv4 : Delta { previous : previous_system_ipv4 , current : system_ipv4 } , ipv6 : Delta { previous : previous_system_ipv6 , current : system_ipv6 } , } , } }
Update interface `id` with its new reachability info.
Update interface ` id ` with its new reachability info .
&mut self
id
Id
new_reachability
IpVersions<StateEvent>