pub async fn send_message<S, M>(&self, address: S, msg: M) -> Result<()>
    where
        S: ToString,
        M: Message + Send + 'static,
    {
        let address = address.to_string();
        let (reply_tx, mut reply_rx) = channel(1);
        let req = NodeMessage::SenderReq(address, reply_tx);

        match self.sender.send(req).await {
            Ok(()) => {
                if let Some(NodeReply::Sender(_, s)) = reply_rx.recv().await {
                    let msg = msg.encode()?;
                    match s.send(msg).await {
                        Ok(()) => Ok(()),
                        Err(_e) => Err(Error::FailedSendMessage.into()),
                    }
                } else {
                    Err(Error::FailedSendMessage.into())
                }
            }
            Err(_e) => Err(Error::FailedSendMessage.into()),
        }
    }
/// Send a message to a particular worker
Send a message to a particular worker
Send a message to a particular worker
pub async fn send_message<S, M>(&self, address: S, msg: M) -> Result<()>
    where
        S: ToString,
        M: Message + Send + 'static,
    {
        let address = address.to_string();
        let (reply_tx, mut reply_rx) = channel(1);
        let req = NodeMessage::SenderReq(address, reply_tx);
        match self.sender.send(req).await {
            Ok(()) => {
                if let Some(NodeReply::Sender(_, s)) = reply_rx.recv().await {
                    let msg = msg.encode()?;
                    match s.send(msg).await {
                        Ok(()) => Ok(()),
                        Err(_e) => Err(Error::FailedSendMessage.into()),
                    }
                } else {
                    Err(Error::FailedSendMessage.into())
                }
            }
            Err(_e) => Err(Error::FailedSendMessage.into()),
        }
    }
pub async fn send_message < S , M > ( & self , address : S , msg : M ) -> Result < ( ) > where S : ToString , M : Message + Send + ' static , { let address = address . to_string ( ) ; let ( reply_tx , mut reply_rx ) = channel ( 1 ) ; let req = NodeMessage :: SenderReq ( address , reply_tx ) ; match self . sender . send ( req ) . await { Ok ( ( ) ) => { if let Some ( NodeReply :: Sender ( _ , s ) ) = reply_rx . recv ( ) . await { let msg = msg . encode ( ) ? ; match s . send ( msg ) . await { Ok ( ( ) ) => Ok ( ( ) ) , Err ( _e ) => Err ( Error :: FailedSendMessage . into ( ) ) , } } else { Err ( Error :: FailedSendMessage . into ( ) ) } } Err ( _e ) => Err ( Error :: FailedSendMessage . into ( ) ) , } }
Send a message to a particular worker
Send a message to a particular worker
&self
address
S
msg
M
&self
address
S
msg
M