48 releases

0.13.0-alpha6 Aug 30, 2024
0.13.0-alpha5 Jul 11, 2024
0.13.0-alpha4 May 31, 2024
0.12.9 Nov 17, 2023
0.7.1 Jul 17, 2022

#508 in Web programming

Download history 221/week @ 2024-05-19 323/week @ 2024-05-26 67/week @ 2024-06-02 63/week @ 2024-06-09 60/week @ 2024-06-16 19/week @ 2024-06-23 109/week @ 2024-07-07 12/week @ 2024-07-14 9/week @ 2024-07-21 52/week @ 2024-07-28 3/week @ 2024-08-04 80/week @ 2024-08-25 21/week @ 2024-09-01

101 downloads per month

MIT license

59KB
1.5K SLoC

aliyun_oss_client 打算采用一种全新的方式来实现

巨大更新,之前使用过的,慎重升级 0.13

目前的实现,代码将大大简化,api 接口也更加起清晰,使用了有限的 rust 语言特性,所以接口更加统一, 大大减少了外部依赖

使用本 lib 创建的 oss 命令行工具:tu6ge/oss-cli,也算是本库的一个演示项目

详细使用案例如下:

use aliyun_oss_client::{types::ObjectQuery, Client, EndPoint};

async fn run() -> Result<(), aliyun_oss_client::Error> {
    let client = Client::from_env()?;

    let buckes = client.get_buckets(&EndPoint::CN_QINGDAO).await?;

    let objects = buckes[0].get_objects(&ObjectQuery::new(), &client).await?;

    let obj_info = objects[0].get_info(&client).await?;

    Ok(())
}

RFC

get Buckets

struct Client {
   key: String,
   secret: String,
}

impl Client {
    async fn get_buckets(&self, endpoint: EndPoint) -> Vec<Bucket> {
        todo!()
    }

    // 导出到自定义的类型
    pub async fn export_buckets<B: DeserializeOwned>(
        &self,
        endpoint: &EndPoint,
    ) -> Result<Vec<B>, OssError> {
        //...
    }
}

get bucket info;

struct Bucket {
    name: String,
    endpoint: EndPoint,
}
impl Bucket{
    async fn get_info(&self, client: &Client) -> BucketInfo {
        todo!()
    }

    // 导出到自定义的类型
    pub async fn export_info<B: DeserializeOwned>(&self, client: &Client) -> Result<B, OssError> {
        //...
    }

    async fn get_object(&self, client: &Client) -> Vec<Object> {
        todo!()
    }

    // 导出到自定义的类型
    pub async fn export_objects<Obj: DeserializeOwned>(
        &self,
        query: &ObjectQuery,
        client: &Client,
    ) -> Result<(Vec<Obj>, NextContinuationToken), OssError> {
        //...
    }
}

get object info

struct Object {
    bucket: Bucket,
    path: ObjectPath,
}
impl Object {
    async fn get_info(&self, client: &Client) -> ObjectInfo {
        todo!()
    }

    async fn upload(&self, client: &Client, content: Vec<u8>) -> Result<(), Error>{
        todo!()
    }
    async fn download(&self, client: &Client) -> Result<Vec<u8>, Error>{
        todo!()
    }
}

Dependencies

~5–16MB
~234K SLoC