Crate pcloud

Source
Expand description

§pCloud API Client Library

tests

This library provides a client for interacting with the pCloud API, implementing the HTTP Json protocol. It offers a set of tools and utilities to facilitate operations with files, folders, and streaming services on pCloud.

§Features

  • File Management: Upload, download, and manage files in your pCloud account.
  • Folder Management: Create, rename, move, and delete folders.
  • Streaming: Stream audio and video content, with customizable parameters like bit rate and resolution.
  • Error Handling: Robust error handling and response parsing from the pCloud API.
  • Flexible Request Building: Customize API requests with various parameters such as content type, speed limits, and more.

§Example Usage

Below is an example of how to use the library to interact with the pCloud API:

use pcloud::Client;
use pcloud::file::FileIdentifier;

#[tokio::main]
async fn main() {
    let client = Client::new("your-api-key");

    // Get file link with file id
    match client.get_file_link(12345).await {
        Ok(link) => println!("File link: {}", link.first_link().unwrap()),
        Err(e) => eprintln!("Error: {}", e),
    }

    // Get file link with file path
    match client.get_file_link("/path/to/file.txt").await {
        Ok(link) => println!("File link: {}", link.first_link().unwrap()),
        Err(e) => eprintln!("Error: {}", e),
    }
}

§Error Handling

The library provides comprehensive error handling. Errors from the API are returned as custom Error types, which can be easily matched and handled in your application. All errors implement the Debug and Display traits for easy logging and display.

§Contributing

Contributions to this project are welcome. Please feel free to submit issues or pull requests with enhancements, bug fixes, or other improvements. Ensure to write tests for new functionality and adhere to the project’s code style.

§License

This project is licensed under the MIT License.

Re-exports§

pub use reqwest;

Modules§

builder
entry
file
folder
stream

Structs§

Client
HTTP client used to interact with the pCloud API.

Enums§

Credentials
Authentication credentials used for pCloud API requests.
Error
Errors that can occur when using the pCloud client or interacting with the API.
Region
Represents a pCloud API region.

Constants§

EU_REGION
Base URL for the EU region.
US_REGION
Base URL for the US region.

Type Aliases§

Result
A type alias for results returned by pCloud API operations.