async fn fwd_observer_callbacks(
    mut source_req_stream: bredr::PeerObserverRequestStream,
    observer: &bredr::PeerObserverProxy,
    id: bt_types::PeerId,
) -> Result<(), Error> {
    while let Some(req) =
        source_req_stream.try_next().await.context("reading peer observer failed")?
    {
        match req {
            bredr::PeerObserverRequest::ServiceFound {
                mut peer_id,
                protocol,
                mut attributes,
                responder,
            } => {
                let mut proto = match protocol {
                    Some(desc) => desc,
                    None => vec![],
                };

                observer
                    .service_found(
                        &mut peer_id,
                        Some(&mut proto.iter_mut()),
                        &mut attributes.iter_mut(),
                    )
                    .await
                    .or_else(|e| {
                        handle_fidl_err(
                            e,
                            format!("unexpected error forwarding observer event for: {}", id),
                        )
                    })?;

                responder.send().or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error acking observer event for: {}", id),
                    )
                })?;
            }

            bredr::PeerObserverRequest::PeerConnected { mut peer_id, mut protocol, responder } => {
                observer.peer_connected(&mut peer_id, &mut protocol.iter_mut()).await.or_else(
                    |e| {
                        handle_fidl_err(
                            e,
                            format!("unexpected error forwarding observer event for: {}", id),
                        )
                    },
                )?;
                responder.send().or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error acking observer event for: {}", id),
                    )
                })?;
            }
            bredr::PeerObserverRequest::ComponentTerminated { component_url, responder } => {
                observer.component_terminated(&component_url).await.or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error forwarding observer event for: {}", id),
                    )
                })?;
                responder.send().or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error acking observer event for: {}", id),
                    )
                })?;
            }
        }
    }
    Ok(())
}
/// Given a request stream and a proxy, forward from one to the other
Given a request stream and a proxy, forward from one to the other
Given a request stream and a proxy forward from one to the other
async fn fwd_observer_callbacks(
    mut source_req_stream: bredr::PeerObserverRequestStream,
    observer: &bredr::PeerObserverProxy,
    id: bt_types::PeerId,
) -> Result<(), Error> {
    while let Some(req) =
        source_req_stream.try_next().await.context("reading peer observer failed")?
    {
        match req {
            bredr::PeerObserverRequest::ServiceFound {
                mut peer_id,
                protocol,
                mut attributes,
                responder,
            } => {
                let mut proto = match protocol {
                    Some(desc) => desc,
                    None => vec![],
                };
                observer
                    .service_found(
                        &mut peer_id,
                        Some(&mut proto.iter_mut()),
                        &mut attributes.iter_mut(),
                    )
                    .await
                    .or_else(|e| {
                        handle_fidl_err(
                            e,
                            format!("unexpected error forwarding observer event for: {}", id),
                        )
                    })?;
                responder.send().or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error acking observer event for: {}", id),
                    )
                })?;
            }
            bredr::PeerObserverRequest::PeerConnected { mut peer_id, mut protocol, responder } => {
                observer.peer_connected(&mut peer_id, &mut protocol.iter_mut()).await.or_else(
                    |e| {
                        handle_fidl_err(
                            e,
                            format!("unexpected error forwarding observer event for: {}", id),
                        )
                    },
                )?;
                responder.send().or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error acking observer event for: {}", id),
                    )
                })?;
            }
            bredr::PeerObserverRequest::ComponentTerminated { component_url, responder } => {
                observer.component_terminated(&component_url).await.or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error forwarding observer event for: {}", id),
                    )
                })?;
                responder.send().or_else(|e| {
                    handle_fidl_err(
                        e,
                        format!("unexpected error acking observer event for: {}", id),
                    )
                })?;
            }
        }
    }
    Ok(())
}
async fn fwd_observer_callbacks ( mut source_req_stream : bredr :: PeerObserverRequestStream , observer : & bredr :: PeerObserverProxy , id : bt_types :: PeerId , ) -> Result < ( ) , Error > { while let Some ( req ) = source_req_stream . try_next ( ) . await . context ( " " ) ? { match req { bredr :: PeerObserverRequest :: ServiceFound { mut peer_id , protocol , mut attributes , responder , } => { let mut proto = match protocol { Some ( desc ) => desc , None => vec ! [ ] , } ; observer . service_found ( & mut peer_id , Some ( & mut proto . iter_mut ( ) ) , & mut attributes . iter_mut ( ) , ) . await . or_else ( | e | { handle_fidl_err ( e , format ! ( " " id ) , ) } ) ? ; responder . send ( ) . or_else ( | e | { handle_fidl_err ( e , format ! ( " " id ) , ) } ) ? ; } bredr :: PeerObserverRequest :: PeerConnected { mut peer_id , mut protocol , responder } => { observer . peer_connected ( & mut peer_id , & mut protocol . iter_mut ( ) ) . await . or_else ( | e | { handle_fidl_err ( e , format ! ( " " id ) , ) } , ) ? ; responder . send ( ) . or_else ( | e | { handle_fidl_err ( e , format ! ( " " id ) , ) } ) ? ; } bredr :: PeerObserverRequest :: ComponentTerminated { component_url , responder } => { observer . component_terminated ( & component_url ) . await . or_else ( | e | { handle_fidl_err ( e , format ! ( " " id ) , ) } ) ? ; responder . send ( ) . or_else ( | e | { handle_fidl_err ( e , format ! ( " " id ) , ) } ) ? ; } } } Ok ( ( ) ) }
Given a request stream and a proxy, forward from one to the other
Given a request stream and a proxy forward from one to the other
source_req_stream
bredr::PeerObserverRequestStream
observer
&bredr::PeerObserverProxy
id
bt_types::PeerId
source_req_stream
bredr::PeerObserverRequestStream
observer
&bredr::PeerObserverProxy
id
bt_types::PeerId