fn update_records_with_rfcomm(
        &self,
        service_records: &mut Vec<ServiceRecord>,
    ) -> Result<(), Error> {
        let mut rfcomm = self.rfcomm_mgr.write();
        let required = service_records.iter().filter(|record| record.requests_rfcomm()).count();
        if required > rfcomm.available_space() {
            return Err(format_err!("Not enough available RFCOMM channels"));
        }

        service_records.iter_mut().filter(|record| record.requests_rfcomm()).for_each(|record| {
            if let Some(channel_number) = rfcomm.reserve_channel() {
                record.set_rfcomm_channel(channel_number).expect("Just checked compatibility");
            }
        });
        Ok(())
    }
/// Updates the `service_records` with assigned RFCOMM channels. Returns an error if channel
/// allocation fails or if there is an insufficient number of free RFCOMM channels.
Updates the `service_records` with assigned RFCOMM channels. Returns an error if channel
allocation fails or if there is an insufficient number of free RFCOMM channels.
Updates the ` service_records ` with assigned RFCOMM channels . Returns an error if channel allocation fails or if there is an insufficient number of free RFCOMM channels .
fn update_records_with_rfcomm(
        &self,
        service_records: &mut Vec<ServiceRecord>,
    ) -> Result<(), Error> {
        let mut rfcomm = self.rfcomm_mgr.write();
        let required = service_records.iter().filter(|record| record.requests_rfcomm()).count();
        if required > rfcomm.available_space() {
            return Err(format_err!("Not enough available RFCOMM channels"));
        }
        service_records.iter_mut().filter(|record| record.requests_rfcomm()).for_each(|record| {
            if let Some(channel_number) = rfcomm.reserve_channel() {
                record.set_rfcomm_channel(channel_number).expect("Just checked compatibility");
            }
        });
        Ok(())
    }
fn update_records_with_rfcomm ( & self , service_records : & mut Vec < ServiceRecord > , ) -> Result < ( ) , Error > { let mut rfcomm = self . rfcomm_mgr . write ( ) ; let required = service_records . iter ( ) . filter ( | record | record . requests_rfcomm ( ) ) . count ( ) ; if required > rfcomm . available_space ( ) { return Err ( format_err ! ( " " ) ) ; } service_records . iter_mut ( ) . filter ( | record | record . requests_rfcomm ( ) ) . for_each ( | record | { if let Some ( channel_number ) = rfcomm . reserve_channel ( ) { record . set_rfcomm_channel ( channel_number ) . expect ( " " ) ; } } ) ; Ok ( ( ) ) }
Updates the `service_records` with assigned RFCOMM channels.
Updates the ` service_records ` with assigned RFCOMM channels .
&self
service_records
&mut Vec<ServiceRecord>
&self
service_records
&mut Vec<ServiceRecord>