pub async fn open_rfcomm_channel(
        &mut self,
        id: PeerId,
        server_channel: ServerChannel,
        responder: bredr::ProfileConnectResponder,
    ) -> Result<(), Error> {
        trace!("Received request to open RFCOMM channel {:?} with peer {:?}", server_channel, id);

        match self.sessions.get(&id).and_then(|s| s.upgrade()) {
            None => {
                // Peer either disconnected or doesn't exist.
                let _ = responder.send(&mut Err(ErrorCode::Failed));
                Err(format_err!("Invalid peer ID {:?}", id))
            }
            Some(session) => {
                let channel_opened_callback =
                    Box::new(move |channel: Result<Channel, ErrorCode>| {
                        let mut channel = channel.map(|c| bredr::Channel::try_from(c).unwrap());
                        responder.send(&mut channel).map_err(|e| format_err!("{:?}", e))
                    });
                session.open_rfcomm_channel(server_channel, channel_opened_callback).await;
                Ok(())
            }
        }
    }
/// Opens an RFCOMM channel specified by `server_channel` with the remote peer.
///
/// Returns an error if there is no session established with the peer.
Opens an RFCOMM channel specified by `server_channel` with the remote peer.
Returns an error if there is no session established with the peer.
Opens an RFCOMM channel specified by ` server_channel ` with the remote peer . Returns an error if there is no session established with the peer .
pub async fn open_rfcomm_channel(
        &mut self,
        id: PeerId,
        server_channel: ServerChannel,
        responder: bredr::ProfileConnectResponder,
    ) -> Result<(), Error> {
        trace!("Received request to open RFCOMM channel {:?} with peer {:?}", server_channel, id);
        match self.sessions.get(&id).and_then(|s| s.upgrade()) {
            None => {
                // Peer either disconnected or doesn't exist.
                let _ = responder.send(&mut Err(ErrorCode::Failed));
                Err(format_err!("Invalid peer ID {:?}", id))
            }
            Some(session) => {
                let channel_opened_callback =
                    Box::new(move |channel: Result<Channel, ErrorCode>| {
                        let mut channel = channel.map(|c| bredr::Channel::try_from(c).unwrap());
                        responder.send(&mut channel).map_err(|e| format_err!("{:?}", e))
                    });
                session.open_rfcomm_channel(server_channel, channel_opened_callback).await;
                Ok(())
            }
        }
    }
pub async fn open_rfcomm_channel ( & mut self , id : PeerId , server_channel : ServerChannel , responder : bredr :: ProfileConnectResponder , ) -> Result < ( ) , Error > { trace ! ( " " server_channel id ) ; match self . sessions . get ( & id ) . and_then ( | s | s . upgrade ( ) ) { None => { // Peer either disconnected or doesn't exist. let _ = responder . send ( & mut Err ( ErrorCode :: Failed ) ) ; Err ( format_err ! ( " " id ) ) } Some ( session ) => { let channel_opened_callback = Box :: new ( move | channel : Result < Channel , ErrorCode > | { let mut channel = channel . map ( | c | bredr :: Channel :: try_from ( c ) . unwrap ( ) ) ; responder . send ( & mut channel ) . map_err ( | e | format_err ! ( " " e ) ) } ) ; session . open_rfcomm_channel ( server_channel , channel_opened_callback ) . await ; Ok ( ( ) ) } } }
Opens an RFCOMM channel specified by `server_channel` with the remote peer.
Opens an RFCOMM channel specified by ` server_channel ` with the remote peer .
&mut self
id
PeerId
server_channel
ServerChannel
responder
bredr::ProfileConnectResponder
&mut self
id
PeerId
server_channel
ServerChannel
responder
bredr::ProfileConnectResponder