Struct pb_async::Client[][src]

pub struct Client { /* fields omitted */ }

PushBullet client

Methods

impl Client
[src]

Create a new client with a given token.

Example usage:

let token = std::env::var("PB_TOKEN").expect("expected PB_TOKEN env var to exist");
let client = pb_async::Client::new(&token)
    .expect("expected client creation to succeed");

Create a new client with a given token and an existing hyper client.

Retrieves information of the logged in user.

Example usage:

extern crate futures;
extern crate pb_async;
extern crate tokio;

use futures::Future;


tokio::executor::spawn(client.get_user().and_then(|user_info| {
    println!("User email is {}", user_info.email);
    Ok(())
}).or_else(|error| {
    eprintln!("error: {}", error);
    Ok(())
}));

Retrieves a list of devices.

Example usage:

extern crate futures;
extern crate pb_async;
extern crate tokio;

use futures::Future;


tokio::executor::spawn(client.list_devices().and_then(|devices| {
    println!("Devices: {:#?}", devices);
    Ok(())
}).or_else(|error| {
    eprintln!("error: {}", error);
    Ok(())
}));

Pushes some data to a target.

Example usage:

extern crate futures;
extern crate pb_async;
extern crate tokio;

use futures::Future;


tokio::executor::spawn(
    client.push(
        pb_async::PushTarget::SelfUser {},
        pb_async::PushData::Note {
            title: "",
            body: "Hello, user!",
        },
    ).or_else(|error| {
        eprintln!("error: {}", error);
        Ok(())
    })
);

Prepares a file for upload prior to pushing it via Client::push.

This method handles file streaming correctly. If you use a streaming hyper::Body, it will be correctly wrapped and the resulting connection won't need to keep the entire file in memory.

Example usage:

extern crate futures;
extern crate pb_async;
extern crate tokio;

use futures::Future;

tokio::executor::spawn(
    client
        .upload_request("hello.txt", "text/plain", "Hello, world!\n".into())
        .and_then(move |file_data| {
            client.push(
                pb_async::PushTarget::SelfUser {},
                pb_async::PushData::File {
                    body: "",
                    file_name: &file_data.file_name,
                    file_type: &file_data.file_type,
                    file_url: &file_data.file_url,
                },
            )
        })
        .or_else(|error| {
            eprintln!("error pushing file: {}", error);
            Ok(())
        }),
);

Auto Trait Implementations

impl Send for Client

impl Sync for Client