fn create_dumby_target_handler(stall_responses: bool) -> TargetHandlerProxy {
        let (target_proxy, mut target_stream) = create_proxy_and_stream::<TargetHandlerMarker>()
            .expect("Error creating TargetHandler endpoint");

        fasync::spawn(async move {
            while let Some(Ok(event)) = target_stream.next().await {
                if stall_responses {
                    fasync::Timer::new(Time::after(Duration::from_millis(2000000))).await;
                }

                let _result = match event {
                    TargetHandlerRequest::GetEventsSupported { responder } => {
                        responder.send(&mut Err(TargetAvcError::RejectedInternalError))
                    }
                    TargetHandlerRequest::GetMediaAttributes { responder } => {
                        responder.send(&mut Ok(MediaAttributes {
                            title: Some("Foo".to_string()),
                            artist_name: Some("Bar".to_string()),
                            ..MediaAttributes::new_empty()
                        }))
                    }
                    TargetHandlerRequest::GetPlayStatus { responder } => {
                        responder.send(&mut Err(TargetAvcError::RejectedInternalError))
                    }
                    TargetHandlerRequest::SendCommand { command, pressed: _, responder } => {
                        if command == AvcPanelCommand::Play {
                            responder.send(&mut Ok(()))
                        } else {
                            responder.send(&mut Err(TargetPassthroughError::CommandNotImplemented))
                        }
                    }
                    TargetHandlerRequest::ListPlayerApplicationSettingAttributes { responder } => {
                        responder.send(&mut Ok(vec![
                            fidl_avrcp::PlayerApplicationSettingAttributeId::Equalizer,
                        ]))
                    }
                    TargetHandlerRequest::GetPlayerApplicationSettings {
                        attribute_ids: _,
                        responder,
                    } => responder.send(&mut Ok(fidl_avrcp::PlayerApplicationSettings {
                        shuffle_mode: Some(fidl_avrcp::ShuffleMode::Off),
                        ..fidl_avrcp::PlayerApplicationSettings::new_empty()
                    })),
                    TargetHandlerRequest::SetPlayerApplicationSettings {
                        requested_settings: _,
                        responder,
                    } => {
                        responder.send(&mut Ok(fidl_avrcp::PlayerApplicationSettings::new_empty()))
                    }
                    TargetHandlerRequest::GetNotification { event_id: _, responder } => {
                        responder.send(&mut Err(TargetAvcError::RejectedInternalError))
                    }
                    TargetHandlerRequest::WatchNotification {
                        event_id: _,
                        current: _,
                        pos_change_interval: _,
                        responder,
                    } => responder.send(&mut Err(TargetAvcError::RejectedInternalError)),
                };
            }
        });

        target_proxy
    }
/// Creates a simple target handler that responds with error and basic values for most commands.
Creates a simple target handler that responds with error and basic values for most commands.
Creates a simple target handler that responds with error and basic values for most commands .
fn create_dumby_target_handler(stall_responses: bool) -> TargetHandlerProxy {
        let (target_proxy, mut target_stream) = create_proxy_and_stream::<TargetHandlerMarker>()
            .expect("Error creating TargetHandler endpoint");
        fasync::spawn(async move {
            while let Some(Ok(event)) = target_stream.next().await {
                if stall_responses {
                    fasync::Timer::new(Time::after(Duration::from_millis(2000000))).await;
                }
                let _result = match event {
                    TargetHandlerRequest::GetEventsSupported { responder } => {
                        responder.send(&mut Err(TargetAvcError::RejectedInternalError))
                    }
                    TargetHandlerRequest::GetMediaAttributes { responder } => {
                        responder.send(&mut Ok(MediaAttributes {
                            title: Some("Foo".to_string()),
                            artist_name: Some("Bar".to_string()),
                            ..MediaAttributes::new_empty()
                        }))
                    }
                    TargetHandlerRequest::GetPlayStatus { responder } => {
                        responder.send(&mut Err(TargetAvcError::RejectedInternalError))
                    }
                    TargetHandlerRequest::SendCommand { command, pressed: _, responder } => {
                        if command == AvcPanelCommand::Play {
                            responder.send(&mut Ok(()))
                        } else {
                            responder.send(&mut Err(TargetPassthroughError::CommandNotImplemented))
                        }
                    }
                    TargetHandlerRequest::ListPlayerApplicationSettingAttributes { responder } => {
                        responder.send(&mut Ok(vec![
                            fidl_avrcp::PlayerApplicationSettingAttributeId::Equalizer,
                        ]))
                    }
                    TargetHandlerRequest::GetPlayerApplicationSettings {
                        attribute_ids: _,
                        responder,
                    } => responder.send(&mut Ok(fidl_avrcp::PlayerApplicationSettings {
                        shuffle_mode: Some(fidl_avrcp::ShuffleMode::Off),
                        ..fidl_avrcp::PlayerApplicationSettings::new_empty()
                    })),
                    TargetHandlerRequest::SetPlayerApplicationSettings {
                        requested_settings: _,
                        responder,
                    } => {
                        responder.send(&mut Ok(fidl_avrcp::PlayerApplicationSettings::new_empty()))
                    }
                    TargetHandlerRequest::GetNotification { event_id: _, responder } => {
                        responder.send(&mut Err(TargetAvcError::RejectedInternalError))
                    }
                    TargetHandlerRequest::WatchNotification {
                        event_id: _,
                        current: _,
                        pos_change_interval: _,
                        responder,
                    } => responder.send(&mut Err(TargetAvcError::RejectedInternalError)),
                };
            }
        });
        target_proxy
    }
fn create_dumby_target_handler ( stall_responses : bool ) -> TargetHandlerProxy { let ( target_proxy , mut target_stream ) = create_proxy_and_stream :: < TargetHandlerMarker > ( ) . expect ( " " ) ; fasync :: spawn ( async move { while let Some ( Ok ( event ) ) = target_stream . next ( ) . await { if stall_responses { fasync :: Timer :: new ( Time :: after ( Duration :: from_millis ( 2000000 ) ) ) . await ; } let _result = match event { TargetHandlerRequest :: GetEventsSupported { responder } => { responder . send ( & mut Err ( TargetAvcError :: RejectedInternalError ) ) } TargetHandlerRequest :: GetMediaAttributes { responder } => { responder . send ( & mut Ok ( MediaAttributes { title : Some ( " " . to_string ( ) ) , artist_name : Some ( " " . to_string ( ) ) , .. MediaAttributes :: new_empty ( ) } ) ) } TargetHandlerRequest :: GetPlayStatus { responder } => { responder . send ( & mut Err ( TargetAvcError :: RejectedInternalError ) ) } TargetHandlerRequest :: SendCommand { command , pressed : _ , responder } => { if command == AvcPanelCommand :: Play { responder . send ( & mut Ok ( ( ) ) ) } else { responder . send ( & mut Err ( TargetPassthroughError :: CommandNotImplemented ) ) } } TargetHandlerRequest :: ListPlayerApplicationSettingAttributes { responder } => { responder . send ( & mut Ok ( vec ! [ fidl_avrcp PlayerApplicationSettingAttributeId Equalizer ] ) ) } TargetHandlerRequest :: GetPlayerApplicationSettings { attribute_ids : _ , responder , } => responder . send ( & mut Ok ( fidl_avrcp :: PlayerApplicationSettings { shuffle_mode : Some ( fidl_avrcp :: ShuffleMode :: Off ) , .. fidl_avrcp :: PlayerApplicationSettings :: new_empty ( ) } ) ) , TargetHandlerRequest :: SetPlayerApplicationSettings { requested_settings : _ , responder , } => { responder . send ( & mut Ok ( fidl_avrcp :: PlayerApplicationSettings :: new_empty ( ) ) ) } TargetHandlerRequest :: GetNotification { event_id : _ , responder } => { responder . send ( & mut Err ( TargetAvcError :: RejectedInternalError ) ) } TargetHandlerRequest :: WatchNotification { event_id : _ , current : _ , pos_change_interval : _ , responder , } => responder . send ( & mut Err ( TargetAvcError :: RejectedInternalError ) ) , } ; } } ) ; target_proxy }
Creates a simple target handler that responds with error and basic values for most commands.
Creates a simple target handler that responds with error and basic values for most commands .
stall_responses
bool
stall_responses
bool