/dbox

(READ ONLY) Unofficial Dropbox SDK for Rust

Primary LanguageRustApache License 2.0Apache-2.0

Unofficial Dropbox SDK for Rust

Build Status

This is an (unofficial, as in not endorsed by) Dropbox SDK for Rust. At present it is not complete, though the API is mostly fleshed out.

Currently it uses 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

  • /files/get_metadata

  • /files/move

Examples

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();
}
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();
}