fn do_handshake(&mut self) -> Result<()> {
        let handshake = self.handshake.lock().unwrap();

        // Handshake is already complete, nothing more to do.
        if handshake.is_completed() {
            return Ok(());
        }

        match handshake.do_handshake() {
            Ok(_) => (),

            Err(Error::Done) => {
                // Try to parse transport parameters as soon as the first flight
                // of handshake data is processed.
                //
                // This is potentially dangerous as the handshake hasn't been
                // completed yet, though it's required to be able to send data
                // in 0.5 RTT.
                let raw_params = handshake.quic_transport_params();

                if !self.parsed_peer_transport_params && !raw_params.is_empty() {
                    let peer_params =
                        TransportParams::decode(&raw_params, self.is_server)?;

                    // Unlock handshake object.
                    drop(handshake);

                    self.parse_peer_transport_params(peer_params)?;
                }

                return Ok(());
            },

            Err(e) => return Err(e),
        };

        self.handshake_completed = handshake.is_completed();

        self.alpn = handshake.alpn_protocol().to_vec();

        let cipher = handshake.cipher();
        let curve = handshake.curve();
        let sigalg = handshake.sigalg();
        let is_resumed = handshake.is_resumed();

        let raw_params = handshake.quic_transport_params();

        if !self.parsed_peer_transport_params && !raw_params.is_empty() {
            let peer_params =
                TransportParams::decode(&raw_params, self.is_server)?;

            // Unlock handshake object.
            drop(handshake);

            self.parse_peer_transport_params(peer_params)?;
        }

        // Once the handshake is completed there's no point in processing 0-RTT
        // packets anymore, so clear the buffer now.
        if self.handshake_completed {
            self.undecryptable_pkts.clear();
        }

        trace!("{} connection established: proto={:?} cipher={:?} curve={:?} sigalg={:?} resumed={} {:?}",
               &self.trace_id, std::str::from_utf8(self.application_proto()),
               cipher, curve, sigalg, is_resumed, self.peer_transport_params);

        Ok(())
    }
/// Continues the handshake.
///
/// If the connection is already established, it does nothing.
Continues the handshake.
If the connection is already established, it does nothing.
Continues the handshake . If the connection is already established it does nothing .
fn do_handshake(&mut self) -> Result<()> {
        let handshake = self.handshake.lock().unwrap();
        // Handshake is already complete, nothing more to do.
        if handshake.is_completed() {
            return Ok(());
        }
        match handshake.do_handshake() {
            Ok(_) => (),
            Err(Error::Done) => {
                // Try to parse transport parameters as soon as the first flight
                // of handshake data is processed.
                //
                // This is potentially dangerous as the handshake hasn't been
                // completed yet, though it's required to be able to send data
                // in 0.5 RTT.
                let raw_params = handshake.quic_transport_params();
                if !self.parsed_peer_transport_params && !raw_params.is_empty() {
                    let peer_params =
                        TransportParams::decode(&raw_params, self.is_server)?;
                    // Unlock handshake object.
                    drop(handshake);
                    self.parse_peer_transport_params(peer_params)?;
                }
                return Ok(());
            },
            Err(e) => return Err(e),
        };
        self.handshake_completed = handshake.is_completed();
        self.alpn = handshake.alpn_protocol().to_vec();
        let cipher = handshake.cipher();
        let curve = handshake.curve();
        let sigalg = handshake.sigalg();
        let is_resumed = handshake.is_resumed();
        let raw_params = handshake.quic_transport_params();
        if !self.parsed_peer_transport_params && !raw_params.is_empty() {
            let peer_params =
                TransportParams::decode(&raw_params, self.is_server)?;
            // Unlock handshake object.
            drop(handshake);
            self.parse_peer_transport_params(peer_params)?;
        }
        // Once the handshake is completed there's no point in processing 0-RTT
        // packets anymore, so clear the buffer now.
        if self.handshake_completed {
            self.undecryptable_pkts.clear();
        }
        trace!("{} connection established: proto={:?} cipher={:?} curve={:?} sigalg={:?} resumed={} {:?}",
               &self.trace_id, std::str::from_utf8(self.application_proto()),
               cipher, curve, sigalg, is_resumed, self.peer_transport_params);
        Ok(())
    }
fn do_handshake ( & mut self ) -> Result < ( ) > { let handshake = self . handshake . lock ( ) . unwrap ( ) ; // Handshake is already complete, nothing more to do. if handshake . is_completed ( ) { return Ok ( ( ) ) ; } match handshake . do_handshake ( ) { Ok ( _ ) => ( ) , Err ( Error :: Done ) => { // Try to parse transport parameters as soon as the first flight // of handshake data is processed. // // This is potentially dangerous as the handshake hasn't been // completed yet, though it's required to be able to send data // in 0.5 RTT. let raw_params = handshake . quic_transport_params ( ) ; if ! self . parsed_peer_transport_params && ! raw_params . is_empty ( ) { let peer_params = TransportParams :: decode ( & raw_params , self . is_server ) ? ; // Unlock handshake object. drop ( handshake ) ; self . parse_peer_transport_params ( peer_params ) ? ; } return Ok ( ( ) ) ; } , Err ( e ) => return Err ( e ) , } ; self . handshake_completed = handshake . is_completed ( ) ; self . alpn = handshake . alpn_protocol ( ) . to_vec ( ) ; let cipher = handshake . cipher ( ) ; let curve = handshake . curve ( ) ; let sigalg = handshake . sigalg ( ) ; let is_resumed = handshake . is_resumed ( ) ; let raw_params = handshake . quic_transport_params ( ) ; if ! self . parsed_peer_transport_params && ! raw_params . is_empty ( ) { let peer_params = TransportParams :: decode ( & raw_params , self . is_server ) ? ; // Unlock handshake object. drop ( handshake ) ; self . parse_peer_transport_params ( peer_params ) ? ; } // Once the handshake is completed there's no point in processing 0-RTT // packets anymore, so clear the buffer now. if self . handshake_completed { self . undecryptable_pkts . clear ( ) ; } trace ! ( " " self trace_id std str from_utf8 ( self application_proto ( ) ) cipher curve sigalg is_resumed self peer_transport_params ) ; Ok ( ( ) ) }
Continues the handshake.
Continues the handshake .
&mut self
&mut self