Crate cos_rust_sdk

Crate cos_rust_sdk 

Source
Expand description

§腾讯云 COS Rust SDK

这是一个用于腾讯云对象存储(COS)的 Rust SDK,提供了完整的 COS API 功能。

§快速开始

use cos_rust_sdk::{Config, CosClient, ObjectClient};
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 创建配置
    let config = Config::new(
        "your-secret-id",
        "your-secret-key",
        "ap-beijing",
        "your-bucket-name-appid"
    ).with_timeout(Duration::from_secs(30));

    // 创建客户端
    let cos_client = CosClient::new(config)?;
    let object_client = ObjectClient::new(cos_client.clone());

    // 上传文件
    let data = b"Hello, COS!";
    object_client.put_object("test.txt", data.to_vec(), Some("text/plain")).await?;

    // 下载文件
    let response = object_client.get_object("test.txt").await?;
    println!("Downloaded: {}", String::from_utf8_lossy(&response.data));

    Ok(())
}

Re-exports§

pub use auth::Auth;
pub use bucket::BucketClient;
pub use bucket::BucketAcl;
pub use bucket::ListObjectsOptions;
pub use bucket::ListObjectsV2Options;
pub use client::CosClient;
pub use config::Config;
pub use error::CosError;
pub use error::Result;
pub use object::ObjectClient;
pub use object::PutObjectResponse;
pub use object::GetObjectResponse;
pub use object::DeleteObjectResponse;
pub use object::HeadObjectResponse;
pub use sts::StsClient;
pub use sts::TemporaryCredentials;
pub use sts::Policy;
pub use sts::Statement;
pub use sts::GetCredentialsRequest;

Modules§

auth
认证模块
bucket
存储桶管理模块
client
HTTP 客户端模块
config
配置模块
error
错误处理模块
object
对象存储操作模块
sts
STS (Security Token Service) 模块

Constants§

USER_AGENT
用户代理字符串
VERSION
SDK 版本