pub async fn open(&mut self, key: Key) -> Result<()> {
        // Create a new channel.
        let channel_handle = self.state.channels.attach_local(key);
        // Safe because attach_local always puts Some(local_id)
        let local_id = channel_handle.local_id().unwrap();
        let discovery_key = *channel_handle.discovery_key();

        // If the channel was already opened from the remote end, verify,
        // and if verification is ok, push a channel open event.
        if channel_handle.is_connected() {
            let (key, remote_capability) =
                self.state.channels.prepare_to_verify(local_id)?;
            self.verify_remote_capability(remote_capability.cloned(), key)?;
            self.queue_event(Event::Open(discovery_key));
        }

        // Tell the remote end about the new channel.
        let capability = self.capability(&key);
        let message = Message::Open(Open {
            discovery_key: discovery_key.to_vec(),
            capability,
        });
        let channel_message = ChannelMessage::new(local_id as u64, message);
        self.io.write_state.queue_frame(Frame::Message(channel_message));
        Ok(())
    }
/// Open a new protocol channel.
Open a new protocol channel.
Open a new protocol channel .
pub async fn open(&mut self, key: Key) -> Result<()> {
        // Create a new channel.
        let channel_handle = self.state.channels.attach_local(key);
        // Safe because attach_local always puts Some(local_id)
        let local_id = channel_handle.local_id().unwrap();
        let discovery_key = *channel_handle.discovery_key();
        // If the channel was already opened from the remote end, verify,
        // and if verification is ok, push a channel open event.
        if channel_handle.is_connected() {
            let (key, remote_capability) =
                self.state.channels.prepare_to_verify(local_id)?;
            self.verify_remote_capability(remote_capability.cloned(), key)?;
            self.queue_event(Event::Open(discovery_key));
        }
        // Tell the remote end about the new channel.
        let capability = self.capability(&key);
        let message = Message::Open(Open {
            discovery_key: discovery_key.to_vec(),
            capability,
        });
        let channel_message = ChannelMessage::new(local_id as u64, message);
        self.io.write_state.queue_frame(Frame::Message(channel_message));
        Ok(())
    }
pub async fn open ( & mut self , key : Key ) -> Result < ( ) > { // Create a new channel. let channel_handle = self . state . channels . attach_local ( key ) ; // Safe because attach_local always puts Some(local_id) let local_id = channel_handle . local_id ( ) . unwrap ( ) ; let discovery_key = * channel_handle . discovery_key ( ) ; // If the channel was already opened from the remote end, verify, // and if verification is ok, push a channel open event. if channel_handle . is_connected ( ) { let ( key , remote_capability ) = self . state . channels . prepare_to_verify ( local_id ) ? ; self . verify_remote_capability ( remote_capability . cloned ( ) , key ) ? ; self . queue_event ( Event :: Open ( discovery_key ) ) ; } // Tell the remote end about the new channel. let capability = self . capability ( & key ) ; let message = Message :: Open ( Open { discovery_key : discovery_key . to_vec ( ) , capability , } ) ; let channel_message = ChannelMessage :: new ( local_id as u64 , message ) ; self . io . write_state . queue_frame ( Frame :: Message ( channel_message ) ) ; Ok ( ( ) ) }
Open a new protocol channel.
Open a new protocol channel .
&mut self
key
Key
&mut self
key
Key