Rust
Control Rclone from Rust using the remote control HTTP API with reqwest.
Rust's reqwest crate is the de facto standard for HTTP requests, offering both async and blocking APIs for interacting with Rclone's remote control API.
Usage
Using async reqwest:
use reqwest;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let response = reqwest::get("http://localhost:5572/")
.await?
.text()
.await?;
println!("{}", response);
Ok(())
}Using blocking reqwest:
use reqwest::blocking;
fn main() -> Result<(), reqwest::Error> {
let response = blocking::get("http://localhost:5572/")?
.text()?;
println!("{}", response);
Ok(())
}Libraries
rclone-sdk
A fully typed SDK for Rclone's remote control API, generated from OpenAPI.
[dependencies]
rclone-sdk = "1.72"
tokio = { version = "1", features = ["full"] }use rclone_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new("http://localhost:5572");
// Get rclone version info
let version = client.core_version(None, None).await?;
let v = version.into_inner();
println!("Rclone {} on {}/{}", v.version, v.os, v.arch);
// List all configured remotes
let remotes = client.config_listremotes(None, None).await?;
println!("Remotes: {:?}", remotes.into_inner().remotes);
// Get storage info for a remote
let about = client.operations_about(None, None, "gdrive:").await?;
let info = about.into_inner();
println!("Storage: {} / {} bytes used", info.used, info.total);
Ok(())
}How is this guide?