pub fn new_advertisement(
        &mut self,
        services: Vec<bredr::ServiceDefinition>,
        proxy: bredr::ConnectionReceiverProxy,
    ) -> Result<(HashSet<bredr::ServiceClassProfileIdentifier>, impl Future<Output = ()>), Error>
    {
        let service_records = parse_service_definitions(services)?;
        let registration_handle = self
            .service_mgr
            .write()
            .register_service(service_records)
            .ok_or(format_err!("Registration of services failed"))?;

        let service_event_stream = proxy.take_event_stream();

        if let Some(s) = self.services.insert(registration_handle, proxy) {
            warn!("Replaced a service at {}: {:?}", registration_handle, s);
        }
        let ids = self
            .service_mgr
            .read()
            .get_service_ids_for_registration_handle(&registration_handle)
            .unwrap_or(&HashSet::new())
            .clone();

        let peer_id = self.id.clone();
        let reg_handle_clone = registration_handle.clone();
        let detached_service = self.services.get(&registration_handle).expect("just added");
        let service_mgr_clone = self.service_mgr.clone();
        let closed_fut = async move {
            let _ = service_event_stream.map(|_| ()).collect::<()>().await;
            detached_service.detach();
            let removed = service_mgr_clone.write().unregister_service(&reg_handle_clone);
            info!("Peer {} unregistered service advertisement: {:?}", peer_id, removed);
        };

        Ok((ids, closed_fut))
    }
/// Attempts to register the services, as a group, specified by `services`.
///
/// Returns 1) The ServiceClassProfileIds of the registered services and 2) A future that should
/// be polled in order to remove the advertisement when `proxy` is closed.
/// Returns an Error if any service in the provided `services` are invalid, or if
/// registration with the ServiceSet failed.
Attempts to register the services, as a group, specified by `services`.
Returns 1) The ServiceClassProfileIds of the registered services and 2) A future that should
be polled in order to remove the advertisement when `proxy` is closed.
Returns an Error if any service in the provided `services` are invalid, or if
registration with the ServiceSet failed.
Attempts to register the services as a group specified by ` services ` . Returns 1 ) The ServiceClassProfileIds of the registered services and 2 ) A future that should be polled in order to remove the advertisement when ` proxy ` is closed . Returns an Error if any service in the provided ` services ` are invalid or if registration with the ServiceSet failed .
pub fn new_advertisement(
        &mut self,
        services: Vec<bredr::ServiceDefinition>,
        proxy: bredr::ConnectionReceiverProxy,
    ) -> Result<(HashSet<bredr::ServiceClassProfileIdentifier>, impl Future<Output = ()>), Error>
    {
        let service_records = parse_service_definitions(services)?;
        let registration_handle = self
            .service_mgr
            .write()
            .register_service(service_records)
            .ok_or(format_err!("Registration of services failed"))?;
        let service_event_stream = proxy.take_event_stream();
        if let Some(s) = self.services.insert(registration_handle, proxy) {
            warn!("Replaced a service at {}: {:?}", registration_handle, s);
        }
        let ids = self
            .service_mgr
            .read()
            .get_service_ids_for_registration_handle(&registration_handle)
            .unwrap_or(&HashSet::new())
            .clone();
        let peer_id = self.id.clone();
        let reg_handle_clone = registration_handle.clone();
        let detached_service = self.services.get(&registration_handle).expect("just added");
        let service_mgr_clone = self.service_mgr.clone();
        let closed_fut = async move {
            let _ = service_event_stream.map(|_| ()).collect::<()>().await;
            detached_service.detach();
            let removed = service_mgr_clone.write().unregister_service(&reg_handle_clone);
            info!("Peer {} unregistered service advertisement: {:?}", peer_id, removed);
        };
        Ok((ids, closed_fut))
    }
pub fn new_advertisement ( & mut self , services : Vec < bredr :: ServiceDefinition > , proxy : bredr :: ConnectionReceiverProxy , ) -> Result < ( HashSet < bredr :: ServiceClassProfileIdentifier > , impl Future < Output = ( ) > ) , Error > { let service_records = parse_service_definitions ( services ) ? ; let registration_handle = self . service_mgr . write ( ) . register_service ( service_records ) . ok_or ( format_err ! ( " " ) ) ? ; let service_event_stream = proxy . take_event_stream ( ) ; if let Some ( s ) = self . services . insert ( registration_handle , proxy ) { warn ! ( " " registration_handle s ) ; } let ids = self . service_mgr . read ( ) . get_service_ids_for_registration_handle ( & registration_handle ) . unwrap_or ( & HashSet :: new ( ) ) . clone ( ) ; let peer_id = self . id . clone ( ) ; let reg_handle_clone = registration_handle . clone ( ) ; let detached_service = self . services . get ( & registration_handle ) . expect ( " " ) ; let service_mgr_clone = self . service_mgr . clone ( ) ; let closed_fut = async move { let _ = service_event_stream . map ( | _ | ( ) ) . collect :: < ( ) > ( ) . await ; detached_service . detach ( ) ; let removed = service_mgr_clone . write ( ) . unregister_service ( & reg_handle_clone ) ; info ! ( " " peer_id removed ) ; } ; Ok ( ( ids , closed_fut ) ) }
Attempts to register the services, as a group, specified by `services`.
Attempts to register the services as a group specified by ` services ` .
&mut self
services
Vec<bredr::ServiceDefinition>
proxy
bredr::ConnectionReceiverProxy
&mut self
services
Vec<bredr::ServiceDefinition>
proxy
bredr::ConnectionReceiverProxy