pub async fn publish<T: AsRef<str>>(
        &self,
        topic: T,
        arguments: Option<WampArgs>,
        arguments_kw: Option<WampKwArgs>,
        acknowledge: bool,
    ) -> Result<Option<WampId>, WampError> {
        let mut options = WampDict::new();

        if acknowledge {
            options.insert("acknowledge".to_string(), Arg::Bool(true));
        }
        // Send the request
        let (res, result) = oneshot::channel();
        if let Err(e) = self.ctl_channel.send(Request::Publish {
            uri: topic.as_ref().to_string(),
            options,
            arguments,
            arguments_kw,
            res,
        }) {
            return Err(From::from(format!(
                "Core never received our request : {}",
                e
            )));
        }

        let pub_id = if acknowledge {
            // Wait for the acknowledgement
            Some(match result.await {
                Ok(Ok(r)) => r.unwrap(),
                Ok(Err(e)) => return Err(From::from(format!("Failed to send publish : {}", e))),
                Err(e) => {
                    return Err(From::from(format!(
                        "Core never returned a response : {}",
                        e
                    )))
                }
            })
        } else {
            None
        };
        Ok(pub_id)
    }
/// Publishes an event on a specific topic
///
/// The caller can set `acknowledge` to true to receive unique IDs from the server
/// for each published event.
Publishes an event on a specific topic
The caller can set `acknowledge` to true to receive unique IDs from the server
for each published event.
Publishes an event on a specific topic The caller can set ` acknowledge ` to true to receive unique IDs from the server for each published event .
pub async fn publish<T: AsRef<str>>(
        &self,
        topic: T,
        arguments: Option<WampArgs>,
        arguments_kw: Option<WampKwArgs>,
        acknowledge: bool,
    ) -> Result<Option<WampId>, WampError> {
        let mut options = WampDict::new();
        if acknowledge {
            options.insert("acknowledge".to_string(), Arg::Bool(true));
        }
        // Send the request
        let (res, result) = oneshot::channel();
        if let Err(e) = self.ctl_channel.send(Request::Publish {
            uri: topic.as_ref().to_string(),
            options,
            arguments,
            arguments_kw,
            res,
        }) {
            return Err(From::from(format!(
                "Core never received our request : {}",
                e
            )));
        }
        let pub_id = if acknowledge {
            // Wait for the acknowledgement
            Some(match result.await {
                Ok(Ok(r)) => r.unwrap(),
                Ok(Err(e)) => return Err(From::from(format!("Failed to send publish : {}", e))),
                Err(e) => {
                    return Err(From::from(format!(
                        "Core never returned a response : {}",
                        e
                    )))
                }
            })
        } else {
            None
        };
        Ok(pub_id)
    }
pub async fn publish < T : AsRef < str > > ( & self , topic : T , arguments : Option < WampArgs > , arguments_kw : Option < WampKwArgs > , acknowledge : bool , ) -> Result < Option < WampId > , WampError > { let mut options = WampDict :: new ( ) ; if acknowledge { options . insert ( " " . to_string ( ) , Arg :: Bool ( true ) ) ; } // Send the request let ( res , result ) = oneshot :: channel ( ) ; if let Err ( e ) = self . ctl_channel . send ( Request :: Publish { uri : topic . as_ref ( ) . to_string ( ) , options , arguments , arguments_kw , res , } ) { return Err ( From :: from ( format ! ( " " e ) ) ) ; } let pub_id = if acknowledge { // Wait for the acknowledgement Some ( match result . await { Ok ( Ok ( r ) ) => r . unwrap ( ) , Ok ( Err ( e ) ) => return Err ( From :: from ( format ! ( " " e ) ) ) , Err ( e ) => { return Err ( From :: from ( format ! ( " " e ) ) ) } } ) } else { None } ; Ok ( pub_id ) }
Publishes an event on a specific topic
The caller can set `acknowledge` to true to receive unique IDs from the server
for each published event.
Publishes an event on a specific topic The caller can set ` acknowledge ` to true to receive unique IDs from the server for each published event .
&self
topic
T
arguments
Option<WampArgs>
arguments_kw
Option<WampKwArgs>
acknowledge
bool