Expand description
S3 Service Adapter
s3s is an ergonomic adapter for building S3-compatible services. It implements the
Amazon S3 REST API as a generic hyper service,
allowing S3-compatible services to focus on the S3 API itself without worrying about
the HTTP layer.
§Features
- S3 REST API Implementation: Comprehensive support for Amazon S3 REST API
- HTTP Layer Abstraction: Built on top of hyper and tower
- Type Safety: Generated data types from AWS Smithy models
- Authentication: Support for AWS Signature Version 4 and Version 2
- Flexible Configuration: Customizable service configuration with hot-reload support
- Extensibility: Custom routes, access control, and validation
§Architecture
The s3s crate converts HTTP requests to S3 operation inputs, calls user-defined
services, and converts operation outputs or errors back to HTTP responses. This allows
you to implement just the S3 business logic while s3s handles all the HTTP protocol
details.
§Getting Started
To build an S3-compatible service:
- Implement the
S3trait for your service - Create an
S3ServiceusingS3ServiceBuilder - Configure optional components (auth, access control, etc.)
- Serve the service using hyper or your favorite HTTP framework
§Example
use s3s::{S3, S3Request, S3Response, S3Result};
use s3s::service::S3ServiceBuilder;
use s3s::dto::{GetObjectInput, GetObjectOutput};
// 1. Implement the S3 trait
#[derive(Clone)]
struct MyS3Service;
#[async_trait::async_trait]
impl S3 for MyS3Service {
async fn get_object(
&self,
req: S3Request<GetObjectInput>
) -> S3Result<S3Response<GetObjectOutput>> {
// Your implementation here
Err(s3s::s3_error!(NotImplemented))
}
// Implement other S3 operations as needed
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 2. Create the S3 service
let service = S3ServiceBuilder::new(MyS3Service).build();
// 3. Serve it (example with hyper)
// See the examples directory for complete server implementations
Ok(())
}§Modules
service: Core service implementation and builderauth: S3 authentication (Signature V4, Signature V2)access: Access control and authorizationconfig: Service configuration and settingsdto: Data transfer objects (generated from AWS Smithy models)host: Virtual host parsing and handlingroute: Custom route supportvalidation: Bucket and object name validationstream: Streaming utilitieschecksum: Checksum algorithmscrypto: Cryptographic utilitiesheader: HTTP header handlingpath: S3 path handlingpost_policy: POST object policy supportregion: AWS region name typexml: XML serialization/deserialization
§Security
⚠️ Important: S3Service and other adapters in this crate have no built-in security
protection. If exposed to the Internet directly, they may be vulnerable to attacks.
It is the user’s responsibility to implement security enhancements such as:
- HTTP body length limits
- Rate limiting
- Back pressure
- Network-level security (firewalls, VPNs, etc.)
§Examples
The crate includes several examples demonstrating different use cases:
axum: Integration with the Axum web frameworkhttps: Running an S3 service with HTTPS/TLS- See the
examplesdirectory for more
§Integration with aws-sdk-s3
For integration with the official AWS SDK and useful types, see the
s3s-aws crate.
§Sample Implementation
For a sample implementation and testing, see the
s3s-fs crate, which implements the S3 API
on top of a file system.
Modules§
- access
- Access control and authorization
- auth
- S3 Authentication
- checksum
- Multi-algorithm checksum computation for S3 objects.
- config
- S3 Service Configuration
- crypto
- Checksum and hash primitives used by S3 signature verification and checksum computation.
- dto
- S3 data transfer objects (DTOs).
- header
- S3-specific HTTP header name constants.
- host
- Virtual-host parsing for S3 request routing.
- path
- A path in the S3 storage.
- post_
policy - POST Object policy parsing and validation.
- region
- S3 region handling
- route
- Custom route support
- service
- S3 Service and Builder
- stream
- Byte-stream types for S3 request and response bodies.
- validation
- Validation API for S3 bucket names.
- xml
- XML serialization and deserialization for S3 request and response bodies.
Macros§
Structs§
- Body
- Http
Error - An error that indicates a failure of an HTTP request.
Passing this error to
hyperwill cause it to abort the connection. - S3Error
- S3Operation
- S3Request
- S3 request
- S3Response
- S3 response
- Trailing
Headers - Trailing headers handle (newtype)
Enums§
Traits§
- S3
- An async trait which represents the S3 API