Skip to main content

Crate rusty_dropbox_sdk

Crate rusty_dropbox_sdk 

Source
Expand description

Unofficial Dropbox HTTP API v2 SDK for Rust.

§Quick start

use rusty_dropbox_sdk::api;
use rusty_dropbox_sdk::api::Service;

let token = std::env::var("DROPBOX_TOKEN")?;
let client = rusty_dropbox_sdk::Client::new(token);
let bearer = client.token();
let req = api::files::list_folder::ListFolderRequest {
    access_token: &bearer,
    payload: Some(api::files::ListFolderArgs {
        path: String::new(),
        recursive: Some(false),
        include_media_info: None,
        include_deleted: None,
        include_has_explicit_shared_members: None,
        include_mounted_folders: None,
        limit: Some(50),
        shared_link: None,
        include_property_groups: None,
        include_non_downloadable_files: None,
    }),
};
let result = req.call().await?;
println!("{:?}", result);

§Organisation

  • api — request/response types grouped by Dropbox namespace (account, auth, check, contacts, file_properties, file_requests, files). Each endpoint has its own submodule with a *Request struct you build and call.
  • Every request implements the Service trait which exposes both call() (async) and call_sync() (blocking) methods.

§Reference

Dropbox HTTP API docs: https://www.dropbox.com/developers/documentation/http/documentation

Modules§

api
auth
OAuth2 helpers for Dropbox.
helpers
High-level helpers built on top of the raw endpoint types.
prelude
Ergonomic re-exports. use rusty_dropbox_sdk::prelude::*; brings in the Service trait (so request.call().await? resolves), the Client token holder, and the files namespace.

Macros§

implement_content_upload_utils
Variant of implement_utils! for upload-side content endpoints. The Request struct must have a pub data: Option<Vec<u8>> field carrying the binary body; the generated impl forwards it through Utils::content_body() so the service macro can attach it as the HTTP body when Headers::ContentTypeAppOctetStream is set.
implement_download_service
Variant of implement_service! for download-class endpoints.
implement_service
Macro to implement the Service trait for a given request type ($req) and response structure ($resp). This macro supports both synchronous and asynchronous API calls.
implement_tests
Every request type targeted by implement_tests! needs a default_test_extras() function that returns a Self with dummy values for all fields that aren’t access_token or payload. Most Request structs only have those two fields; default_test_extras() is generated by implement_utils! as an empty struct literal using struct-update syntax. Content-upload Request structs override it to set data: None.
implement_utils

Structs§

Client
RefreshConfig
TypedError
Decode a Dropbox error response body into a human-readable anyhow::Error.

Constants§

USER_AGENT
User-Agent advertised on every request. Lets Dropbox support trace traffic from this SDK and lets you bump the version when filing issues against them.