pub fn new(mut io: IO<T>, result: Option<noise::HandshakeResult>)
        -> Result<Self>
    {
        // setup core
        if io.options.encrypted && result.is_some() {
            let handshake = result.as_ref().unwrap();
            io.read_state.upgrade_with_handshake(&handshake)?;
            io.write_state.upgrade_with_handshake(&handshake)?;
        }
        io.read_state.set_frame_type(FrameType::Message);

        // setup channels
        let (outbound_tx, outbound_rx) = async_channel::unbounded();

        Ok(Self {
            io,
            state: Stage {
                handshake: result,
                channels: ChannelMap::new(),
                outbound_tx,
                outbound_rx,
                queued_events: VecDeque::new(),
            },
        })
    }
/// Create a new [Protocol] after completing the handshake.
Create a new [Protocol] after completing the handshake.
Create a new [ Protocol ] after completing the handshake .
pub fn new(mut io: IO<T>, result: Option<noise::HandshakeResult>)
        -> Result<Self>
    {
        // setup core
        if io.options.encrypted && result.is_some() {
            let handshake = result.as_ref().unwrap();
            io.read_state.upgrade_with_handshake(&handshake)?;
            io.write_state.upgrade_with_handshake(&handshake)?;
        }
        io.read_state.set_frame_type(FrameType::Message);
        // setup channels
        let (outbound_tx, outbound_rx) = async_channel::unbounded();
        Ok(Self {
            io,
            state: Stage {
                handshake: result,
                channels: ChannelMap::new(),
                outbound_tx,
                outbound_rx,
                queued_events: VecDeque::new(),
            },
        })
    }
pub fn new ( mut io : IO < T > , result : Option < noise :: HandshakeResult > ) -> Result < Self > { // setup core if io . options . encrypted && result . is_some ( ) { let handshake = result . as_ref ( ) . unwrap ( ) ; io . read_state . upgrade_with_handshake ( & handshake ) ? ; io . write_state . upgrade_with_handshake ( & handshake ) ? ; } io . read_state . set_frame_type ( FrameType :: Message ) ; // setup channels let ( outbound_tx , outbound_rx ) = async_channel :: unbounded ( ) ; Ok ( Self { io , state : Stage { handshake : result , channels : ChannelMap :: new ( ) , outbound_tx , outbound_rx , queued_events : VecDeque :: new ( ) , } , } ) }
Create a new [Protocol] after completing the handshake.
Create a new [ Protocol ] after completing the handshake .
io
IO<T>
result
Option<noise::HandshakeResult>
io
IO<T>
result
Option<noise::HandshakeResult>