/// Notifies proper sink in the case the notification listener count is
/// non-zero and we aren't already listening for changes to the type or there
/// are no more listeners and we are actively listening.
Notifies proper sink in the case the notification listener count is
non-zero and we aren't already listening for changes to the type or there
are no more listeners and we are actively listening.
Notifies proper sink in the case the notification listener count is non - zero and we aren ' t already listening for changes to the type or there are no more listeners and we are actively listening .
async fn process_listen(&mut self, setting_type: SettingType, size: u64) {
        let candidate = self.get_handler(setting_type).await;
        if candidate.is_none() {
            return;
        }
        let sender = candidate.unwrap();
        let listening = self.active_listeners.contains(&setting_type);
        if size == 0 && listening {
            // FIXME: use `Vec::remove_item` upon stabilization
            let listener_to_remove =
                self.active_listeners.iter().enumerate().find(|(_i, elem)| **elem == setting_type);
            if let Some((i, _elem)) = listener_to_remove {
                self.active_listeners.remove(i);
            }
            sender.unbounded_send(Command::ChangeState(State::EndListen)).ok();
        } else if size > 0 && !listening {
            self.active_listeners.push(setting_type);
            sender
                .unbounded_send(Command::ChangeState(State::Listen(
                    self.notification_sender.clone(),
                )))
                .ok();
        }
    }
async fn process_listen ( & mut self , setting_type : SettingType , size : u64 ) { let candidate = self . get_handler ( setting_type ) . await ; if candidate . is_none ( ) { return ; } let sender = candidate . unwrap ( ) ; let listening = self . active_listeners . contains ( & setting_type ) ; if size == 0 && listening { // FIXME: use `Vec::remove_item` upon stabilization let listener_to_remove = self . active_listeners . iter ( ) . enumerate ( ) . find ( | ( _i , elem ) | * * elem == setting_type ) ; if let Some ( ( i , _elem ) ) = listener_to_remove { self . active_listeners . remove ( i ) ; } sender . unbounded_send ( Command :: ChangeState ( State :: EndListen ) ) . ok ( ) ; } else if size > 0 && ! listening { self . active_listeners . push ( setting_type ) ; sender . unbounded_send ( Command :: ChangeState ( State :: Listen ( self . notification_sender . clone ( ) , ) ) ) . ok ( ) ; } }
Notifies proper sink in the case the notification listener count is
non-zero and we aren't already listening for changes to the type or there
are no more listeners and we are actively listening.
Notifies proper sink in the case the notification listener count is non - zero and we aren ' t already listening for changes to the type or there are no more listeners and we are actively listening .
&mut self
setting_type
SettingType
size
u64