= Unofficial Dropbox SDK for Rust

image:https://travis-ci.org/pwoolcoc/dropbox-rs.svg?branch=master["Build Status", link="https://travis-ci.org/pwoolcoc/dropbox-rs"]

This is an (unofficial, as in not endorsed by) Dropbox SDK for
https://rust-lang.org[Rust]. At present it is not complete, though the API is
mostly fleshed out.

Currently it uses https://hyperium.github.io[Hyper] to communicate with the
Dropbox API, but this is swappable, to allow a user to use their preferred HTTP
library, or use more advanced features.

It is also very much lacking in tests and documentation.

== What's working

Right now the following API calls are available:

  - `/files/copy`
  - `/files/create_folder`
  - `/files/delete`
  - `/files/download`
  - `/files/list_folder`
  - `/files/upload`

== Examples


[source,rust]
.Basic example
----
extern crate dbox;

use dbox::client::Client;
use dbox::files;

const ACCESS_TOKEN: &'static str = "MY_ACCESS_TOKEN";

fn main() {
    let client = Client::new(ACCESS_TOKEN);
    let (metadata, response) = files::download(&client, "/path/to/file").unwrap();
}
----


[source,rust]
.With non-Hyper client
----
// compile with `cargo build --no-default-features`
extern crate dbox;
extern crate rustc_serialize;

use dbox::{DropboxClient, Result, Response};
use dbox::files;

struct MyClient;

impl DropboxClient for MyClient {
    fn access_token() -> &str {
        // return access token
    }

    fn request<T>(&self, url: &str, headers: &mut BTreeMap<String, String>, body: &T) -> Result<Response>
        where T: rustc_serialize::Encodable + Clone
    {
        // implement http request here
    }
}

fn main() {
    let client = MyClient;
    let (metadata, response) = files::download(&client, "/path/to/file").unwrap();
}
----

