pub async fn send_all_commands(
        &mut self,
        cmds: Vec<Command>,
    ) -> Result<Vec<CommandResponse>, String> {
        let mut promises: Vec<PinkySwear<CommandResponse>> = vec![];
        let messages: Vec<Result<Message, tokio_tungstenite::tungstenite::Error>> = cmds
            .iter()
            .map(|cmd| {
                let (message, promise) = self.prepare_command_to_send(cmd);
                promises.push(promise);
                Result::Ok(message)
            })
            .collect();

        let mut iter = futures_util::stream::iter(messages);
        self.write.borrow_mut().send_all(&mut iter).await.unwrap();
        Result::Ok(join_all(promises).await)
    }
/// Sends mutliple commands and waits for responses
Sends mutliple commands and waits for responses
Sends mutliple commands and waits for responses
pub async fn send_all_commands(
        &mut self,
        cmds: Vec<Command>,
    ) -> Result<Vec<CommandResponse>, String> {
        let mut promises: Vec<PinkySwear<CommandResponse>> = vec![];
        let messages: Vec<Result<Message, tokio_tungstenite::tungstenite::Error>> = cmds
            .iter()
            .map(|cmd| {
                let (message, promise) = self.prepare_command_to_send(cmd);
                promises.push(promise);
                Result::Ok(message)
            })
            .collect();
        let mut iter = futures_util::stream::iter(messages);
        self.write.borrow_mut().send_all(&mut iter).await.unwrap();
        Result::Ok(join_all(promises).await)
    }
pub async fn send_all_commands ( & mut self , cmds : Vec < Command > , ) -> Result < Vec < CommandResponse > , String > { let mut promises : Vec < PinkySwear < CommandResponse > > = vec ! [ ] ; let messages : Vec < Result < Message , tokio_tungstenite :: tungstenite :: Error > > = cmds . iter ( ) . map ( | cmd | { let ( message , promise ) = self . prepare_command_to_send ( cmd ) ; promises . push ( promise ) ; Result :: Ok ( message ) } ) . collect ( ) ; let mut iter = futures_util :: stream :: iter ( messages ) ; self . write . borrow_mut ( ) . send_all ( & mut iter ) . await . unwrap ( ) ; Result :: Ok ( join_all ( promises ) . await ) }
Sends mutliple commands and waits for responses
Sends mutliple commands and waits for responses
&mut self
cmds
Vec<Command>
&mut self
cmds
Vec<Command>