pub async fn run(mut self) -> Result<(), Error> {
        let mut ping_interval =
            tokio::time::interval_at(Instant::now().add(PING_INTERVAL), PING_INTERVAL);

        let recv_timeout = tokio::time::sleep(RECV_TIMEOUT);
        tokio::pin!(recv_timeout);

        loop {
            tokio::select! {
                Some(res) = self.stream.next() => match res {
                    Ok(msg) => {
                        // Reset the receive timeout every time we successfully
                        // receive a message from the remote endpoint.
                        recv_timeout.as_mut().reset(Instant::now().add(RECV_TIMEOUT));
                        self.handle_incoming_msg(msg).await?
                    },
                    Err(e) => return Err(
                        Error::web_socket(
                            "failed to read from WebSocket connection".to_string(),
                            e
                        ),
                    ),
                },
                Some(cmd) = self.cmd_rx.recv() => match cmd {
                    DriverCommand::Subscribe(subs_cmd) => self.subscribe(subs_cmd).await?,
                    DriverCommand::Unsubscribe(unsubs_cmd) => self.unsubscribe(unsubs_cmd).await?,
                    DriverCommand::SimpleRequest(req_cmd) => self.simple_request(req_cmd).await?,
                    DriverCommand::Terminate => return self.close().await,
                },
                _ = ping_interval.tick() => self.ping().await?,
                _ = &mut recv_timeout => {
                    return Err(Error::web_socket_timeout(RECV_TIMEOUT));
                }
            }
        }
    }
/// Executes the WebSocket driver, which manages the underlying WebSocket
/// transport.
Executes the WebSocket driver, which manages the underlying WebSocket
transport.
Executes the WebSocket driver which manages the underlying WebSocket transport .
pub async fn run(mut self) -> Result<(), Error> {
        let mut ping_interval =
            tokio::time::interval_at(Instant::now().add(PING_INTERVAL), PING_INTERVAL);
        let recv_timeout = tokio::time::sleep(RECV_TIMEOUT);
        tokio::pin!(recv_timeout);
        loop {
            tokio::select! {
                Some(res) = self.stream.next() => match res {
                    Ok(msg) => {
                        // Reset the receive timeout every time we successfully
                        // receive a message from the remote endpoint.
                        recv_timeout.as_mut().reset(Instant::now().add(RECV_TIMEOUT));
                        self.handle_incoming_msg(msg).await?
                    },
                    Err(e) => return Err(
                        Error::web_socket(
                            "failed to read from WebSocket connection".to_string(),
                            e
                        ),
                    ),
                },
                Some(cmd) = self.cmd_rx.recv() => match cmd {
                    DriverCommand::Subscribe(subs_cmd) => self.subscribe(subs_cmd).await?,
                    DriverCommand::Unsubscribe(unsubs_cmd) => self.unsubscribe(unsubs_cmd).await?,
                    DriverCommand::SimpleRequest(req_cmd) => self.simple_request(req_cmd).await?,
                    DriverCommand::Terminate => return self.close().await,
                },
                _ = ping_interval.tick() => self.ping().await?,
                _ = &mut recv_timeout => {
                    return Err(Error::web_socket_timeout(RECV_TIMEOUT));
                }
            }
        }
    }
pub async fn run ( mut self ) -> Result < ( ) , Error > { let mut ping_interval = tokio :: time :: interval_at ( Instant :: now ( ) . add ( PING_INTERVAL ) , PING_INTERVAL ) ; let recv_timeout = tokio :: time :: sleep ( RECV_TIMEOUT ) ; tokio :: pin ! ( recv_timeout ) ; loop { tokio :: select ! { Some ( res ) self stream next ( ) match res { Ok ( msg ) { // Reset the receive timeout every time we successfully // receive a message from the remote endpoint. recv_timeout as_mut ( ) reset ( Instant now ( ) add ( RECV_TIMEOUT ) ) self handle_incoming_msg ( msg ) await } Err ( e ) return Err ( Error web_socket ( " " to_string ( ) e ) ) } Some ( cmd ) self cmd_rx recv ( ) match cmd { DriverCommand Subscribe ( subs_cmd ) self subscribe ( subs_cmd ) await DriverCommand Unsubscribe ( unsubs_cmd ) self unsubscribe ( unsubs_cmd ) await DriverCommand SimpleRequest ( req_cmd ) self simple_request ( req_cmd ) await DriverCommand Terminate return self close ( ) await } ping_interval tick ( ) self ping ( ) await mut recv_timeout { return Err ( Error web_socket_timeout ( RECV_TIMEOUT ) ) } } } }
Executes the WebSocket driver, which manages the underlying WebSocket
transport.
Executes the WebSocket driver which manages the underlying WebSocket transport .
mut self