pub async fn handle_device_listener_registry_request_stream(
        mut stream: fidl_ui_policy::DeviceListenerRegistryRequestStream,
        listeners: Arc<Mutex<Vec<fidl_ui_policy::MediaButtonsListenerProxy>>>,
        last_event: Arc<Mutex<Option<fidl_ui_input::MediaButtonsEvent>>>,
    ) -> Result<(), Error> {
        while let Some(request) = stream
            .try_next()
            .await
            .context("Error handling device listener registry request stream")?
        {
            match request {
                fidl_ui_policy::DeviceListenerRegistryRequest::RegisterListener {
                    listener,
                    responder,
                } => {
                    if let Ok(proxy) = listener.into_proxy() {
                        // Add the listener to the registry.
                        let mut listeners_locked = listeners.lock().await;
                        listeners_locked.push(proxy.clone());

                        // Send the listener the last media button event.
                        if let Some(event) = last_event.lock().await.clone() {
                            if !is_empty_media_buttons_event(&event) {
                                let _ = proxy.on_event(event).await;
                            }
                        }
                    }
                    let _ = responder.send();
                }
                _ => {}
            }
        }

        Ok(())
    }
/// Handles the incoming DeviceListenerRegistryRequestStream.
///
/// This method will end when the request stream is closed. If the stream closes with an
/// error the error will be returned in the Result.
///
/// # Parameters
/// - `listeners`: The media button listeners to send events to.
/// - `last_event`: The last event sent to the listeners.
/// - `stream`: The stream of DeviceListenerRegistryRequestStream.
Handles the incoming DeviceListenerRegistryRequestStream.
This method will end when the request stream is closed. If the stream closes with an
error the error will be returned in the Result.
Handles the incoming DeviceListenerRegistryRequestStream . This method will end when the request stream is closed . If the stream closes with an error the error will be returned in the Result .
pub async fn handle_device_listener_registry_request_stream(
        mut stream: fidl_ui_policy::DeviceListenerRegistryRequestStream,
        listeners: Arc<Mutex<Vec<fidl_ui_policy::MediaButtonsListenerProxy>>>,
        last_event: Arc<Mutex<Option<fidl_ui_input::MediaButtonsEvent>>>,
    ) -> Result<(), Error> {
        while let Some(request) = stream
            .try_next()
            .await
            .context("Error handling device listener registry request stream")?
        {
            match request {
                fidl_ui_policy::DeviceListenerRegistryRequest::RegisterListener {
                    listener,
                    responder,
                } => {
                    if let Ok(proxy) = listener.into_proxy() {
                        // Add the listener to the registry.
                        let mut listeners_locked = listeners.lock().await;
                        listeners_locked.push(proxy.clone());
                        // Send the listener the last media button event.
                        if let Some(event) = last_event.lock().await.clone() {
                            if !is_empty_media_buttons_event(&event) {
                                let _ = proxy.on_event(event).await;
                            }
                        }
                    }
                    let _ = responder.send();
                }
                _ => {}
            }
        }
        Ok(())
    }
pub async fn handle_device_listener_registry_request_stream ( mut stream : fidl_ui_policy :: DeviceListenerRegistryRequestStream , listeners : Arc < Mutex < Vec < fidl_ui_policy :: MediaButtonsListenerProxy > > > , last_event : Arc < Mutex < Option < fidl_ui_input :: MediaButtonsEvent > > > , ) -> Result < ( ) , Error > { while let Some ( request ) = stream . try_next ( ) . await . context ( " " ) ? { match request { fidl_ui_policy :: DeviceListenerRegistryRequest :: RegisterListener { listener , responder , } => { if let Ok ( proxy ) = listener . into_proxy ( ) { // Add the listener to the registry. let mut listeners_locked = listeners . lock ( ) . await ; listeners_locked . push ( proxy . clone ( ) ) ; // Send the listener the last media button event. if let Some ( event ) = last_event . lock ( ) . await . clone ( ) { if ! is_empty_media_buttons_event ( & event ) { let _ = proxy . on_event ( event ) . await ; } } } let _ = responder . send ( ) ; } _ => { } } } Ok ( ( ) ) }
Handles the incoming DeviceListenerRegistryRequestStream.
Handles the incoming DeviceListenerRegistryRequestStream .
stream
fidl_ui_policy::DeviceListenerRegistryRequestStream
listeners
Arc<Mutex<Vec<fidl_ui_policy::MediaButtonsListenerProxy>>>
last_event
Arc<Mutex<Option<fidl_ui_input::MediaButtonsEvent>>>
stream
fidl_ui_policy::DeviceListenerRegistryRequestStream
The stream of DeviceListenerRegistryRequestStream.
The stream of DeviceListenerRegistryRequestStream .
listeners
Arc<Mutex<Vec<fidl_ui_policy::MediaButtonsListenerProxy>>>
The media button listeners to send events to.
The media button listeners to send events to .
last_event
Arc<Mutex<Option<fidl_ui_input::MediaButtonsEvent>>>
The last event sent to the listeners.
The last event sent to the listeners .