1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
use js_sys::{JsString, Object};
use wasm_bindgen::prelude::*;
use web_sys::ReadableStream;

use crate::Headers;

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2Bucket)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type R2Bucket;

    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = head)]
    pub fn head(this: &R2Bucket, key: String) -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = get)]
    pub fn get(this: &R2Bucket, key: String, options: JsValue) -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = put)]
    pub fn put(this: &R2Bucket, key: String, value: JsValue, options: JsValue)
        -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = delete)]
    pub fn delete(this: &R2Bucket, key: String) -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = list)]
    pub fn list(this: &R2Bucket, options: JsValue) -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = createMultipartUpload)]
    pub fn create_multipart_upload(
        this: &R2Bucket,
        key: String,
        options: JsValue,
    ) -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = resumeMultipartUpload)]
    pub fn resume_multipart_upload(this: &R2Bucket, key: String, upload_id: String) -> JsValue;
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2Object)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type R2Object;

    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = key)]
    pub fn key(this: &R2Object) -> String;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = version)]
    pub fn version(this: &R2Object) -> String;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = size)]
    pub fn size(this: &R2Object) -> u32;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = etag)]
    pub fn etag(this: &R2Object) -> String;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = httpEtag)]
    pub fn http_etag(this: &R2Object) -> String;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = uploaded)]
    pub fn uploaded(this: &R2Object) -> ::js_sys::Date;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = httpMetadata)]
    pub fn http_metadata(this: &R2Object) -> R2HttpMetadata;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = customMetadata)]
    pub fn custom_metadata(this: &R2Object) -> Object;
    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = range)]
    pub fn range(this: &R2Object) -> R2Range;
    #[wasm_bindgen(structural, method, js_class=R2Object, js_name = writeHttpMetadata, catch)]
    pub fn write_http_metadata(this: &R2Object, headers: Headers) -> Result<Object, JsValue>;
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=R2Object, js_name=R2ObjectBody)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type R2ObjectBody;

    #[wasm_bindgen(structural, method, getter, js_class=R2ObjectBody, js_name = body)]
    pub fn body(this: &R2ObjectBody) -> ReadableStream;
    #[wasm_bindgen(structural, method, getter, js_class=R2ObjectBody, js_name = bodyUsed)]
    pub fn body_used(this: &R2ObjectBody) -> bool;
    #[wasm_bindgen(structural, method, js_class=R2ObjectBody, js_name = arrayBuffer)]
    pub fn array_buffer(this: &R2ObjectBody) -> js_sys::Promise;
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2UploadedPart)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type R2UploadedPart;

    #[wasm_bindgen(structural, method, getter, js_class=R2UploadedPart, js_name = partNumber)]
    pub fn part_number(this: &R2UploadedPart) -> u16;
    #[wasm_bindgen(structural, method, getter, js_class=R2UploadedPart, js_name = etag)]
    pub fn etag(this: &R2UploadedPart) -> String;
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2MultipartUpload)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type R2MultipartUpload;

    #[wasm_bindgen(structural, method, getter, js_class=R2MultipartUpload, js_name = key)]
    pub fn key(this: &R2MultipartUpload) -> String;
    #[wasm_bindgen(structural, method, getter, js_class=R2MultipartUpload, js_name = uploadId)]
    pub fn upload_id(this: &R2MultipartUpload) -> String;
    #[wasm_bindgen(structural, method, js_class=R2MultipartUpload, js_name = uploadPart)]
    pub fn upload_part(
        this: &R2MultipartUpload,
        part_number: u16,
        value: JsValue,
    ) -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2MultipartUpload, js_name = abort)]
    pub fn abort(this: &R2MultipartUpload) -> ::js_sys::Promise;
    #[wasm_bindgen(structural, method, js_class=R2MultipartUpload, js_name = complete)]
    pub fn complete(this: &R2MultipartUpload, uploaded_parts: Vec<JsValue>) -> ::js_sys::Promise;
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2Objects)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type R2Objects;

    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = objects)]
    pub fn objects(this: &R2Objects) -> Vec<R2Object>;
    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = truncated)]
    pub fn truncated(this: &R2Objects) -> bool;
    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = cursor)]
    pub fn cursor(this: &R2Objects) -> Option<String>;
    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = delimitedPrefixes)]
    pub fn delimited_prefixes(this: &R2Objects) -> Vec<JsString>;
}

#[wasm_bindgen]
#[derive(Debug, Clone)]
pub struct R2Range {
    pub offset: Option<u32>,
    pub length: Option<u32>,
    pub suffix: Option<u32>,
}

#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2HttpMetadata)]
    #[derive(Debug, Clone, PartialEq, Eq)]
    pub type R2HttpMetadata;

    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentType)]
    pub fn content_type(this: &R2HttpMetadata) -> Option<String>;
    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentLanguage)]
    pub fn content_language(this: &R2HttpMetadata) -> Option<String>;
    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentDisposition)]
    pub fn content_disposition(this: &R2HttpMetadata) -> Option<String>;
    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentEncoding)]
    pub fn content_encoding(this: &R2HttpMetadata) -> Option<String>;
    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = cacheControl)]
    pub fn cache_control(this: &R2HttpMetadata) -> Option<String>;
    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = cacheExpiry)]
    pub fn cache_expiry(this: &R2HttpMetadata) -> Option<::js_sys::Date>;
}