/// Update state based on the new reachability info.
Update state based on the new reachability info.
Update state based on the new reachability info .
fn update_state(&mut self, id: Id, name: &str, reachability: IpVersions<StateEvent>) {
        let StateDelta { port, system } = self.state.update(id, reachability);
        let () = port.with_version(|proto, delta| {
            if delta.change_observed() {
                let &Delta { previous, current } = delta;
                if let Some(previous) = previous {
                    log::info!(
                        "interface updated {:?} {:?} current: {:?} previous: {:?}",
                        id,
                        proto,
                        current,
                        previous
                    );
                } else {
                    log::info!("new interface {:?} {:?}: {:?}", id, proto, current);
                }
                let () = log_state(self.interface_node(id, name), proto, current.state);
                *self.stats.state_updates.entry(id).or_insert(0) += 1;
            }
        });
        let () = system.with_version(|proto, delta| {
            if delta.change_observed() {
                let &Delta { previous, current } = delta;
                if let Some(previous) = previous {
                    log::info!(
                        "system updated {:?} current: {:?}, previous: {:?}",
                        proto,
                        current,
                        previous,
                    );
                } else {
                    log::info!("initial system state {:?}: {:?}", proto, current);
                }
                let () = log_state(self.system_node.as_mut(), proto, current.state.state);
            }
        });
    }
fn update_state ( & mut self , id : Id , name : & str , reachability : IpVersions < StateEvent > ) { let StateDelta { port , system } = self . state . update ( id , reachability ) ; let ( ) = port . with_version ( | proto , delta | { if delta . change_observed ( ) { let & Delta { previous , current } = delta ; if let Some ( previous ) = previous { log :: info ! ( " " id proto current previous ) ; } else { log :: info ! ( " " id proto current ) ; } let ( ) = log_state ( self . interface_node ( id , name ) , proto , current . state ) ; * self . stats . state_updates . entry ( id ) . or_insert ( 0 ) += 1 ; } } ) ; let ( ) = system . with_version ( | proto , delta | { if delta . change_observed ( ) { let & Delta { previous , current } = delta ; if let Some ( previous ) = previous { log :: info ! ( " " proto current previous ) ; } else { log :: info ! ( " " proto current ) ; } let ( ) = log_state ( self . system_node . as_mut ( ) , proto , current . state . state ) ; } } ) ; }
Update state based on the new reachability info.
Update state based on the new reachability info .
&mut self
id
Id
name
&str
reachability
IpVersions<StateEvent>