Skip to content

Instantly share code, notes, and snippets.

@LucioFranco
Forked from davidbarsky/aws.rs
Last active August 27, 2019 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucioFranco/50f6fd2c761df06bc5b90408a622b68d to your computer and use it in GitHub Desktop.
Save LucioFranco/50f6fd2c761df06bc5b90408a622b68d to your computer and use it in GitHub Desktop.
#![feature(async_await)]
use failure::{Fail, Error};
use std::future::Future;
use std::pin::Pin;
/// `S3Request` is a trait that specifies:
/// - the service request/response pairing.
/// - the service protocol (json, rest-json, rest-xml, or query)
/// - optionally, additional metadata.
/// - mechanisms of serializing/deserializing this data
/// - where the request should be routed.
/// In summary, S3Request is a trait encodes shows how
/// a Botocore object can be transformer into an `http::Request<hyper::Body>`,
/// and how the resulting `http::Response<hyper::Body>` can be transformed
/// into a typed Botocore object.
trait AWSResource {
type Response;
}
struct GetObjectRequest;
struct GetObjectResponse;
#[derive(Fail, Debug)]
#[fail(display = "invalid toolchain name")]
struct GetObjectError;
struct S3 {
inner: BoxHttpService,
}
impl S3 {
pub async fn get_object(&mut self, req: GetObjectRequest) -> Result<GetObjectResponse, S3Error>
{
let req = req.into_http();
self.inner.call(req).await.map_err(S3Error::from)
}
}
async fn run() -> Result<(), Error> {
let s3 = S3::default(;
let _response = s3.get_object(GetObjectRequest::default()).await?;
Ok(())
}
fn main() {
// assume this is spawned to tokio, romio, or https://github.com/rustasync/runtime.
let _res = run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment