async fn process_request(
        &mut self,
        id: u64,
        setting_type: SettingType,
        request: SettingRequest,
    ) {
        let candidate = self.get_handler(setting_type).await;
        match candidate {
            None => {
                self.conduit_sender.send(ConduitData::Event(SettingEvent::Response(
                    id,
                    Err(format_err!("no handler for requested type")),
                )));
            }
            Some(command_sender) => {
                let (responder, receiver) =
                    futures::channel::oneshot::channel::<SettingResponseResult>();
                let sender_clone = self.conduit_sender.clone();
                let error_sender_clone = self.conduit_sender.clone();
                fasync::spawn(
                    async move {
                        let response =
                            receiver.await.context("getting response from controller")?;
                        sender_clone.send(ConduitData::Event(SettingEvent::Response(id, response)));

                        Ok(())
                    }
                    .unwrap_or_else(move |e: anyhow::Error| {
                        error_sender_clone
                            .send(ConduitData::Event(SettingEvent::Response(id, Err(e))));
                    }),
                );

                command_sender.unbounded_send(Command::HandleRequest(request, responder)).ok();
            }
        }
    }
/// Forwards request to proper sink. A new task is spawned in order to receive
/// the response. If no sink is available, an error is immediately reported
/// back.
Forwards request to proper sink. A new task is spawned in order to receive
the response. If no sink is available, an error is immediately reported
back.
Forwards request to proper sink . A new task is spawned in order to receive the response . If no sink is available an error is immediately reported back .
async fn process_request(
        &mut self,
        id: u64,
        setting_type: SettingType,
        request: SettingRequest,
    ) {
        let candidate = self.get_handler(setting_type).await;
        match candidate {
            None => {
                self.conduit_sender.send(ConduitData::Event(SettingEvent::Response(
                    id,
                    Err(format_err!("no handler for requested type")),
                )));
            }
            Some(command_sender) => {
                let (responder, receiver) =
                    futures::channel::oneshot::channel::<SettingResponseResult>();
                let sender_clone = self.conduit_sender.clone();
                let error_sender_clone = self.conduit_sender.clone();
                fasync::spawn(
                    async move {
                        let response =
                            receiver.await.context("getting response from controller")?;
                        sender_clone.send(ConduitData::Event(SettingEvent::Response(id, response)));
                        Ok(())
                    }
                    .unwrap_or_else(move |e: anyhow::Error| {
                        error_sender_clone
                            .send(ConduitData::Event(SettingEvent::Response(id, Err(e))));
                    }),
                );
                command_sender.unbounded_send(Command::HandleRequest(request, responder)).ok();
            }
        }
    }
async fn process_request ( & mut self , id : u64 , setting_type : SettingType , request : SettingRequest , ) { let candidate = self . get_handler ( setting_type ) . await ; match candidate { None => { self . conduit_sender . send ( ConduitData :: Event ( SettingEvent :: Response ( id , Err ( format_err ! ( " " ) ) , ) ) ) ; } Some ( command_sender ) => { let ( responder , receiver ) = futures :: channel :: oneshot :: channel :: < SettingResponseResult > ( ) ; let sender_clone = self . conduit_sender . clone ( ) ; let error_sender_clone = self . conduit_sender . clone ( ) ; fasync :: spawn ( async move { let response = receiver . await . context ( " " ) ? ; sender_clone . send ( ConduitData :: Event ( SettingEvent :: Response ( id , response ) ) ) ; Ok ( ( ) ) } . unwrap_or_else ( move | e : anyhow :: Error | { error_sender_clone . send ( ConduitData :: Event ( SettingEvent :: Response ( id , Err ( e ) ) ) ) ; } ) , ) ; command_sender . unbounded_send ( Command :: HandleRequest ( request , responder ) ) . ok ( ) ; } } }
Forwards request to proper sink.
Forwards request to proper sink .
&mut self
id
u64
setting_type
SettingType
request
SettingRequest
&mut self
id
u64
setting_type
SettingType
request
SettingRequest