fn process_response(
        &self,
        response: Result<Payload, anyhow::Error>,
        store: &mut HashMap<Key, Data>,
    ) -> Option<Result<SettingInfo, Error>> {
        match response {
            Ok(Payload::Response(Ok(Some(setting_info)))) => {
                let key = Key::Identifier(LAST_VALUE_KEY);

                let return_val = match (store.get(&key), self.change_function.as_ref()) {
                    // Apply the change function to determine if we should notify listeners.
                    (Some(Data::SettingInfo(info)), Some(change_function))
                        if !(change_function.function)(info, &setting_info) =>
                    {
                        None
                    }
                    // No change function used, compare the new info with the old.
                    (Some(Data::SettingInfo(info)), None) if *info == setting_info => None,
                    _ => Some(Ok(setting_info)),
                };

                if let Some(Ok(ref info)) = return_val {
                    let _ = store.insert(key, Data::SettingInfo(info.clone()));
                }

                return_val
            }
            Ok(Payload::Response(Err(error))) => Some(Err(error)),
            Err(error) => {
                fx_log_warn!(
                    "An error occurred while watching {:?}:{:?}",
                    self.setting_type,
                    error
                );
                Some(Err(match error.root_cause().downcast_ref::<Error>() {
                    Some(error) => error.clone(),
                    _ => crate::handler::base::Error::CommunicationError,
                }))
            }
            _ => {
                panic!("invalid variant {:?}", response);
            }
        }
    }
/// Returns a non-empty value when the last response should be returned to the caller. The lack
/// of a response indicates the watched value has not changed and watching will continue.
Returns a non-empty value when the last response should be returned to the caller. The lack
of a response indicates the watched value has not changed and watching will continue.
Returns a non - empty value when the last response should be returned to the caller . The lack of a response indicates the watched value has not changed and watching will continue .
fn process_response(
        &self,
        response: Result<Payload, anyhow::Error>,
        store: &mut HashMap<Key, Data>,
    ) -> Option<Result<SettingInfo, Error>> {
        match response {
            Ok(Payload::Response(Ok(Some(setting_info)))) => {
                let key = Key::Identifier(LAST_VALUE_KEY);
                let return_val = match (store.get(&key), self.change_function.as_ref()) {
                    // Apply the change function to determine if we should notify listeners.
                    (Some(Data::SettingInfo(info)), Some(change_function))
                        if !(change_function.function)(info, &setting_info) =>
                    {
                        None
                    }
                    // No change function used, compare the new info with the old.
                    (Some(Data::SettingInfo(info)), None) if *info == setting_info => None,
                    _ => Some(Ok(setting_info)),
                };
                if let Some(Ok(ref info)) = return_val {
                    let _ = store.insert(key, Data::SettingInfo(info.clone()));
                }
                return_val
            }
            Ok(Payload::Response(Err(error))) => Some(Err(error)),
            Err(error) => {
                fx_log_warn!(
                    "An error occurred while watching {:?}:{:?}",
                    self.setting_type,
                    error
                );
                Some(Err(match error.root_cause().downcast_ref::<Error>() {
                    Some(error) => error.clone(),
                    _ => crate::handler::base::Error::CommunicationError,
                }))
            }
            _ => {
                panic!("invalid variant {:?}", response);
            }
        }
    }
fn process_response ( & self , response : Result < Payload , anyhow :: Error > , store : & mut HashMap < Key , Data > , ) -> Option < Result < SettingInfo , Error > > { match response { Ok ( Payload :: Response ( Ok ( Some ( setting_info ) ) ) ) => { let key = Key :: Identifier ( LAST_VALUE_KEY ) ; let return_val = match ( store . get ( & key ) , self . change_function . as_ref ( ) ) { // Apply the change function to determine if we should notify listeners. ( Some ( Data :: SettingInfo ( info ) ) , Some ( change_function ) ) if ! ( change_function . function ) ( info , & setting_info ) => { None } // No change function used, compare the new info with the old. ( Some ( Data :: SettingInfo ( info ) ) , None ) if * info == setting_info => None , _ => Some ( Ok ( setting_info ) ) , } ; if let Some ( Ok ( ref info ) ) = return_val { let _ = store . insert ( key , Data :: SettingInfo ( info . clone ( ) ) ) ; } return_val } Ok ( Payload :: Response ( Err ( error ) ) ) => Some ( Err ( error ) ) , Err ( error ) => { fx_log_warn ! ( " " self setting_type error ) ; Some ( Err ( match error . root_cause ( ) . downcast_ref :: < Error > ( ) { Some ( error ) => error . clone ( ) , _ => crate :: handler :: base :: Error :: CommunicationError , } ) ) } _ => { panic ! ( " " response ) ; } } }
Returns a non-empty value when the last response should be returned to the caller.
Returns a non - empty value when the last response should be returned to the caller .
&self
response
Result<Payload, anyhow::Error>
store
&mut HashMap<Key, Data>
&self
response
Result<Payload, anyhow::Error>
store
&mut HashMap<Key, Data>