/// Add a given service into the table in case it is not already there and
/// return the service ID, otherwise return None. The last_seen timestamp
/// will be set to the current time in both cases.
Add a given service into the table in case it is not already there and
return the service ID, otherwise return None. The last_seen timestamp
will be set to the current time in both cases.
Add a given service into the table in case it is not already there and return the service ID otherwise return None . The last_seen timestamp will be set to the current time in both cases .
fn add_internal(&mut self, static_svc: bool, svc: Service) -> Option<u16> {
        let key   = get_service_table_key(&svc);
        let index = self.map.get(&key)
            .map(|index| *index);
        if svc == Service::ControlProtocol {
            None
        } else if let Some(index) = index {
            let elem = &mut self.services[index];
            elem.last_seen = get_utc_timestamp();
            elem.service   = svc;
            None
        } else {
            let svc_id = (self.services.len() + 1) as u16;
            let elem   = ServiceTableElement {
                service_id:     svc_id,
                service:        svc,
                static_service: static_svc,
                last_seen:      get_utc_timestamp(),
                active:         true
            };
            self.map.insert(key, self.services.len());
            self.services.push(elem);
            Some(svc_id)
        }
    }
fn add_internal ( & mut self , static_svc : bool , svc : Service ) -> Option < u16 > { let key = get_service_table_key ( & svc ) ; let index = self . map . get ( & key ) . map ( | index | * index ) ; if svc == Service :: ControlProtocol { None } else if let Some ( index ) = index { let elem = & mut self . services [ index ] ; elem . last_seen = get_utc_timestamp ( ) ; elem . service = svc ; None } else { let svc_id = ( self . services . len ( ) + 1 ) as u16 ; let elem = ServiceTableElement { service_id : svc_id , service : svc , static_service : static_svc , last_seen : get_utc_timestamp ( ) , active : true } ; self . map . insert ( key , self . services . len ( ) ) ; self . services . push ( elem ) ; Some ( svc_id ) } }
Add a given service into the table in case it is not already there and
return the service ID, otherwise return None.
Add a given service into the table in case it is not already there and return the service ID otherwise return None .
&mut self
static_svc
bool
svc
Service