Ossify - Alibaba Cloud OSS SDK for Rust
A modern, easy-to-use, and reqwest-powered Rust SDK for Alibaba Cloud Object Storage Service (OSS). Built with developer experience in mind, this SDK provides a clean, intuitive API that makes working with OSS straightforward and enjoyable.
✨ Key Features
- 🚀 Reqwest-Powered: Built on top of the battle-tested
reqwestHTTP client with full async/await support - 🎯 Developer-Friendly: Clean, intuitive API designed for ease of use and developer productivity
- 🔐 Secure by Default: Full support for OSS authentication, including temporary credentials and STS tokens
- 📦 Complete Coverage: Comprehensive support for bucket operations, object management, and multipart uploads
- 🛡️ Type-Safe: Leverages Rust's type system to prevent common errors at compile time
- ⚡ Performance: Optimized for speed with streaming support and efficient memory usage
- 🔧 Flexible: Multiple URL styles (Virtual Hosted, Path-style, CNAME) and customizable configurations
🚀 Quick Start
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["full"] }
Basic Example
use Client;
use BucketOperations;
use *;
async
📚 Core Operations
Bucket Operations
use *;
// Create a bucket
let config = new;
client.put_bucket.await?;
// List objects
let options = new.max_keys;
let result = client.list_objects.await?;
// Get bucket info
let info = client.get_bucket_info.await?;
println!;
// Delete bucket
client.delete_bucket.await?;
Object Operations
use *;
// Upload object with options
let options = new
.content_type
.storage_class;
client.put_object.await?;
// Download with range
let params = new;
let options = new.range;
let content = client.get_object.await?;
// Get object metadata
let metadata = client.head_object.await?;
println!;
// Delete object
client.delete_object.await?;
Multipart Upload
use *;
// Initialize multipart upload
let result = client.initiate_multipart_upload.await?;
let upload_id = result.upload_id;
// Upload parts
let part1 = client.upload_part.await?;
let part2 = client.upload_part.await?;
// Complete upload
let parts = vec!;
let options = new.parts;
client.complete_multipart_upload.await?;
🔧 Configuration
Client Builder
The SDK provides a flexible builder pattern for configuration:
use ;
use Duration;
let client = builder
.endpoint
.public_endpoint // Optional
.region
.bucket
.access_key_id
.access_key_secret
.security_token // Optional, for temporary credentials
.http_timeout
.url_style // VirtualHosted, Path, or CName
.build?;
URL Styles
- VirtualHosted (default):
https://bucket.oss-cn-hangzhou.aliyuncs.com/object - Path:
https://oss-cn-hangzhou.aliyuncs.com/bucket/object - CNAME:
https://custom-domain.com/object
Authentication
The SDK supports multiple authentication methods:
// Basic credentials
let client = builder
.access_key_id
.access_key_secret
.build?;
// With STS token (temporary credentials)
let client = builder
.access_key_id
.access_key_secret
.security_token
.build?;
🌟 Advanced Features
Presigned URLs
Generate presigned URLs for secure, temporary access:
use QueryAuthOptions;
let auth_options = builder
.expires_in // 1 hour
.build?;
let url = client.presign_get_object.await?;
println!;
Streaming Support
Efficient handling of large files with streaming:
// The SDK uses reqwest's streaming capabilities internally
// for efficient memory usage with large objects
Error Handling
Comprehensive error types for robust applications:
use Error;
match client.get_object.await
🏗️ Architecture
This SDK is built with modern Rust practices:
- Async/Await: Full async support powered by
tokioandreqwest - Type Safety: Leverages Rust's type system to prevent errors
- Zero-Copy: Efficient memory usage with
CowandBytes - Modular Design: Clean separation of concerns with trait-based architecture
- Comprehensive: Covers all major OSS operations
Core Dependencies
- reqwest: HTTP client with async support and robust error handling
- tokio: Async runtime for high-performance I/O
- serde: Serialization/deserialization for API requests/responses
- chrono: Date/time handling for OSS operations
- bytes: Efficient byte buffer management
📖 Documentation
For detailed documentation and examples, visit:
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with reqwest - the amazing HTTP client for Rust
- Inspired by the need for a modern, easy-to-use OSS SDK in the Rust ecosystem
- Thanks to the Alibaba Cloud team for providing comprehensive OSS documentation