Skip to main content

s3_wasi_http/api/
put_object.rs

1use anyhow::Result;
2use wstd::http::{Body, Method};
3
4use super::{S3RequestBuilder, S3RequestData, S3ResponseData};
5
6pub struct PutObjectRequest {
7    pub key: String,
8    pub body: Vec<u8>,
9}
10
11impl S3RequestData for PutObjectRequest {
12    type ResponseType = PutObjectResponse;
13
14    fn into_builder(
15        &self,
16        access_key: &str,
17        secret_key: &str,
18        region: &str,
19        endpoint: &str,
20    ) -> Result<S3RequestBuilder<Self::ResponseType>> {
21        let mut builder = S3RequestBuilder::new(
22            Method::PUT,
23            &self.key,
24            access_key,
25            secret_key,
26            region,
27            endpoint,
28        );
29        builder.body(&self.body);
30
31        Ok(builder)
32    }
33}
34
35pub struct PutObjectResponse {}
36
37impl S3ResponseData for PutObjectResponse {
38    async fn parse_body(_response: &mut Body) -> Result<Self>
39    where
40        Self: Sized,
41    {
42        Ok(Self {})
43    }
44}