fn send_message<T>(&self, client: &HyperClient,
                       data: T, ignore_missing: bool)
                      -> BerylliumFuture<MessageStatus>
        where T: Serialize
    {
        info!("Sending message...");
        let url = format!("/bot/messages?ignore_missing={}", ignore_missing);
        let f = self.request(client, Method::Post, &url, Some(data));
        let f = f.and_then(|(code, headers, body)| {
            utils::acquire_body_with_err(&headers, body).and_then(move |vec| {
                // This happens only when we haven't sent the encrypted message
                // for all the devices in the conversation (i.e., we don't have all the devices).
                if code == StatusCode::PreconditionFailed {
                    info!("It looks like we're missing devices.");
                    let res = serde_json::from_slice::<Devices>(&vec)
                                         .map(MessageStatus::Failed)
                                         .map_err(BerylliumError::from);
                    future::result(res)
                } else if code.is_success() {
                    info!("Successfully sent the message.");
                    future::ok(MessageStatus::Sent)
                } else {
                    let res = serde_json::from_slice::<SerdeValue>(&vec)
                                         .map_err(BerylliumError::from);
                    let msg = format!("Error sending message. Response: {:?}", res);
                    future::err(BerylliumError::Other(msg))
                }
            })
        });

        Box::new(f)
    }
/// Send raw message. This is usually called by `send_encrypted_message`
Send raw message. This is usually called by `send_encrypted_message`
Send raw message . This is usually called by ` send_encrypted_message `
fn send_message<T>(&self, client: &HyperClient,
                       data: T, ignore_missing: bool)
                      -> BerylliumFuture<MessageStatus>
        where T: Serialize
    {
        info!("Sending message...");
        let url = format!("/bot/messages?ignore_missing={}", ignore_missing);
        let f = self.request(client, Method::Post, &url, Some(data));
        let f = f.and_then(|(code, headers, body)| {
            utils::acquire_body_with_err(&headers, body).and_then(move |vec| {
                // This happens only when we haven't sent the encrypted message
                // for all the devices in the conversation (i.e., we don't have all the devices).
                if code == StatusCode::PreconditionFailed {
                    info!("It looks like we're missing devices.");
                    let res = serde_json::from_slice::<Devices>(&vec)
                                         .map(MessageStatus::Failed)
                                         .map_err(BerylliumError::from);
                    future::result(res)
                } else if code.is_success() {
                    info!("Successfully sent the message.");
                    future::ok(MessageStatus::Sent)
                } else {
                    let res = serde_json::from_slice::<SerdeValue>(&vec)
                                         .map_err(BerylliumError::from);
                    let msg = format!("Error sending message. Response: {:?}", res);
                    future::err(BerylliumError::Other(msg))
                }
            })
        });
        Box::new(f)
    }
fn send_message < T > ( & self , client : & HyperClient , data : T , ignore_missing : bool ) -> BerylliumFuture < MessageStatus > where T : Serialize { info ! ( " " ) ; let url = format ! ( " " ignore_missing ) ; let f = self . request ( client , Method :: Post , & url , Some ( data ) ) ; let f = f . and_then ( | ( code , headers , body ) | { utils :: acquire_body_with_err ( & headers , body ) . and_then ( move | vec | { // This happens only when we haven't sent the encrypted message // for all the devices in the conversation (i.e., we don't have all the devices). if code == StatusCode :: PreconditionFailed { info ! ( " " ) ; let res = serde_json :: from_slice :: < Devices > ( & vec ) . map ( MessageStatus :: Failed ) . map_err ( BerylliumError :: from ) ; future :: result ( res ) } else if code . is_success ( ) { info ! ( " " ) ; future :: ok ( MessageStatus :: Sent ) } else { let res = serde_json :: from_slice :: < SerdeValue > ( & vec ) . map_err ( BerylliumError :: from ) ; let msg = format ! ( " " res ) ; future :: err ( BerylliumError :: Other ( msg ) ) } } ) } ) ; Box :: new ( f ) }
Send raw message.
Send raw message .
&self
client
&HyperClient
data
T
ignore_missing
bool