47 个版本
0.13.0-alpha5 | 2024 年 7 月 11 日 |
---|---|
0.12.10 | 2024 年 5 月 19 日 |
0.12.9 | 2023 年 11 月 17 日 |
0.12.5 | 2023 年 7 月 19 日 |
0.7.1 | 2022 年 7 月 17 日 |
#644 在 网页编程
每月 67 次下载
57KB
1.5K SLoC
aliyun_oss_client 打算采用一种全新的方式来实现
重大更新,之前使用过的,请谨慎升级到 0.13
目前的实现,代码将大大简化,API 接口也更加清晰,使用了有限的 Rust 语言特性,因此接口更加统一,大大减少了外部依赖
使用本库创建的 OSS 命令行工具:tu6ge/oss-cli,也可以算作本库的一个演示项目
以下是一些详细的使用案例:
获取存储桶
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> {
//...
}
}
获取存储桶信息;
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> {
//...
}
}
获取对象信息
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!()
}
}
依赖项
~5–16MB
~236K SLoC