pub async fn send_msg<'a, E: Encodable + 'a, D: Decodable + Debug>(
        &'a self,
        msg: E,
    ) -> Result<QmiResult<D>, QmuxError> {
        let svc_id = SvcId(msg.svc_id());
        let mut need_id = false;
        {
            let map = self.clients.read();
            // allocate a client id for this service
            if map.get(&svc_id).is_none() {
                need_id = true;
            }
        }
        if need_id {
            use qmi_protocol::CTL::{GetClientIdReq, GetClientIdResp};
            fx_log_info!("allocating a client ID for service: {}", svc_id.0);
            let resp: QmiResult<GetClientIdResp> =
                await!(self.send_msg_actual(GetClientIdReq::new(svc_id.0)))?;
            let client_id_resp = resp.unwrap(); // TODO from trait for QmiError to QmuxError
            let mut map = self.clients.write();
            assert_eq!(client_id_resp.svc_type, svc_id.0);
            map.insert(svc_id, ClientId(client_id_resp.client_id));
        }
        Ok(await!(self.send_msg_actual(msg))?)
    }
/// Send a QMI message and allocate the client IDs for the service
/// if they have not yet been
Send a QMI message and allocate the client IDs for the service
if they have not yet been
Send a QMI message and allocate the client IDs for the service if they have not yet been
pub async fn send_msg<'a, E: Encodable + 'a, D: Decodable + Debug>(
        &'a self,
        msg: E,
    ) -> Result<QmiResult<D>, QmuxError> {
        let svc_id = SvcId(msg.svc_id());
        let mut need_id = false;
        {
            let map = self.clients.read();
            // allocate a client id for this service
            if map.get(&svc_id).is_none() {
                need_id = true;
            }
        }
        if need_id {
            use qmi_protocol::CTL::{GetClientIdReq, GetClientIdResp};
            fx_log_info!("allocating a client ID for service: {}", svc_id.0);
            let resp: QmiResult<GetClientIdResp> =
                await!(self.send_msg_actual(GetClientIdReq::new(svc_id.0)))?;
            let client_id_resp = resp.unwrap(); // TODO from trait for QmiError to QmuxError
            let mut map = self.clients.write();
            assert_eq!(client_id_resp.svc_type, svc_id.0);
            map.insert(svc_id, ClientId(client_id_resp.client_id));
        }
        Ok(await!(self.send_msg_actual(msg))?)
    }
pub async fn send_msg < ' a , E : Encodable + ' a , D : Decodable + Debug > ( & ' a self , msg : E , ) -> Result < QmiResult < D > , QmuxError > { let svc_id = SvcId ( msg . svc_id ( ) ) ; let mut need_id = false ; { let map = self . clients . read ( ) ; // allocate a client id for this service if map . get ( & svc_id ) . is_none ( ) { need_id = true ; } } if need_id { use qmi_protocol :: CTL :: { GetClientIdReq , GetClientIdResp } ; fx_log_info ! ( " " svc_id 0 ) ; let resp : QmiResult < GetClientIdResp > = await ! ( self send_msg_actual ( GetClientIdReq new ( svc_id 0 ) ) ) ? ; let client_id_resp = resp . unwrap ( ) ; // TODO from trait for QmiError to QmuxError let mut map = self . clients . write ( ) ; assert_eq ! ( client_id_resp svc_type svc_id 0 ) ; map . insert ( svc_id , ClientId ( client_id_resp . client_id ) ) ; } Ok ( await ! ( self send_msg_actual ( msg ) ) ? ) }
Send a QMI message and allocate the client IDs for the service
if they have not yet been
Send a QMI message and allocate the client IDs for the service if they have not yet been
&'a self
msg
E
&'a self
msg
E