async fn add_mock_piconet_component(
    builder: &mut RealmBuilder,
    name: String,
    id: bt_types::PeerId,
    profile_svc_path: String,
    observer_src: Option<bredr::PeerObserverProxy>,
) -> Result<(), Error> {
    // If there is no observer, make a channel and fill it in. The server end
    // of the channel is passed to a future which just reads the channel to
    // completion.
    let observer = observer_src.unwrap_or_else(|| {
        let (proxy, stream) =
            f_end::create_proxy_and_stream::<bredr::PeerObserverMarker>().unwrap();
        fasync::Task::local(async move {
            let _ = drain_observer(stream).await;
        })
        .detach();
        proxy
    });

    builder
        .add_component(
            name,
            ComponentSource::Mock(mock::Mock::new(move |m: mock::MockHandles| {
                let observer = observer.clone();
                Box::pin(piconet_member(m, id, profile_svc_path.clone(), observer))
            })),
        )
        .await
        .map(|_| ())
        .map_err(|e| e.into())
}
/// Add the mock piconet member to the Realm. If observer_src is None a channel
/// is created and the server end shipped off to a future to be drained.
Add the mock piconet member to the Realm. If observer_src is None a channel
is created and the server end shipped off to a future to be drained.
Add the mock piconet member to the Realm . If observer_src is None a channel is created and the server end shipped off to a future to be drained .
async fn add_mock_piconet_component(
    builder: &mut RealmBuilder,
    name: String,
    id: bt_types::PeerId,
    profile_svc_path: String,
    observer_src: Option<bredr::PeerObserverProxy>,
) -> Result<(), Error> {
    // If there is no observer, make a channel and fill it in. The server end
    // of the channel is passed to a future which just reads the channel to
    // completion.
    let observer = observer_src.unwrap_or_else(|| {
        let (proxy, stream) =
            f_end::create_proxy_and_stream::<bredr::PeerObserverMarker>().unwrap();
        fasync::Task::local(async move {
            let _ = drain_observer(stream).await;
        })
        .detach();
        proxy
    });
    builder
        .add_component(
            name,
            ComponentSource::Mock(mock::Mock::new(move |m: mock::MockHandles| {
                let observer = observer.clone();
                Box::pin(piconet_member(m, id, profile_svc_path.clone(), observer))
            })),
        )
        .await
        .map(|_| ())
        .map_err(|e| e.into())
}
async fn add_mock_piconet_component ( builder : & mut RealmBuilder , name : String , id : bt_types :: PeerId , profile_svc_path : String , observer_src : Option < bredr :: PeerObserverProxy > , ) -> Result < ( ) , Error > { // If there is no observer, make a channel and fill it in. The server end // of the channel is passed to a future which just reads the channel to // completion. let observer = observer_src . unwrap_or_else ( | | { let ( proxy , stream ) = f_end :: create_proxy_and_stream :: < bredr :: PeerObserverMarker > ( ) . unwrap ( ) ; fasync :: Task :: local ( async move { let _ = drain_observer ( stream ) . await ; } ) . detach ( ) ; proxy } ) ; builder . add_component ( name , ComponentSource :: Mock ( mock :: Mock :: new ( move | m : mock :: MockHandles | { let observer = observer . clone ( ) ; Box :: pin ( piconet_member ( m , id , profile_svc_path . clone ( ) , observer ) ) } ) ) , ) . await . map ( | _ | ( ) ) . map_err ( | e | e . into ( ) ) }
Add the mock piconet member to the Realm.
Add the mock piconet member to the Realm .
builder
&mut RealmBuilder
name
String
id
bt_types::PeerId
profile_svc_path
String
observer_src
Option<bredr::PeerObserverProxy>
builder
&mut RealmBuilder
name
String
id
bt_types::PeerId
profile_svc_path
String
observer_src
Option<bredr::PeerObserverProxy>