Crate rusty_oss

Crate rusty_oss 

Source
Expand description

A simple, pure Rust Aliyun OSS client following a Sans-IO approach

The rusty-oss crate provides a convenient API for signing, building and parsing Aliyun OSS requests and responses. It follows a Sans-IO approach, meaning that the library itself doesn’t send any of the requests. It’s the reposibility of the user to choose an HTTP client, be it synchronous or asynchronous, and use it to send the requests.

§Basic getting started example

use std::env;
use std::time::Duration;
use rusty_oss::{Bucket, Credentials, OSSAction, UrlStyle};

// setting up a bucket
let endpoint = "https://oss-cn-hangzhou.aliyuncs.com".parse().expect("endpoint is a valid Url");
let path_style = UrlStyle::VirtualHost;
let name = "examplebucket";
let region = "cn-hangzhou";
let bucket = Bucket::new(endpoint, path_style, name, region).expect("Url has a valid scheme and host");

// setting up the credentials
let key = env::var("ALIYUN_OSS_ACCESS_KEY").expect("ALIYUN_OSS_ACCESS_KEY is set and a valid String");
let secret = env::var("ALIYUN_OSS_ACCESS_SECRET").expect("ALIYUN_OSS_ACCESS_SECRET is set and a valid String");
let credentials = Credentials::new(key, secret);

// signing a request
let presigned_url_duration = Duration::from_secs(60 * 60);
let action = bucket.get_object(Some(&credentials), "duck.jpg");
println!("GET {}", action.sign(presigned_url_duration));

Re-exports§

pub use self::actions::OSSAction;
pub use self::credentials::Credentials;

Modules§

actions
OSS request building and response parsing support
credentials
Credentials management types
signing

Structs§

Bucket
An OSS bucket
Map
A map used for holding query string paramenters or headers

Enums§

BucketError
Method
The HTTP request method for an OSSAction.
UrlStyle
The request url format of a OSS bucket.