worker_plus_sys/
r2.rs

1use js_sys::{JsString, Object};
2use wasm_bindgen::prelude::*;
3use web_sys::ReadableStream;
4
5use crate::Headers;
6
7#[wasm_bindgen]
8extern "C" {
9    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2Bucket)]
10    #[derive(Debug, Clone, PartialEq, Eq)]
11    pub type R2Bucket;
12
13    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = head)]
14    pub fn head(this: &R2Bucket, key: String) -> ::js_sys::Promise;
15    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = get)]
16    pub fn get(this: &R2Bucket, key: String, options: JsValue) -> ::js_sys::Promise;
17    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = put)]
18    pub fn put(this: &R2Bucket, key: String, value: JsValue, options: JsValue)
19        -> ::js_sys::Promise;
20    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = delete)]
21    pub fn delete(this: &R2Bucket, key: String) -> ::js_sys::Promise;
22    #[wasm_bindgen(structural, method, js_class=R2Bucket, js_name = list)]
23    pub fn list(this: &R2Bucket, options: JsValue) -> ::js_sys::Promise;
24}
25
26#[wasm_bindgen]
27extern "C" {
28    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2Object)]
29    #[derive(Debug, Clone, PartialEq, Eq)]
30    pub type R2Object;
31
32    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = key)]
33    pub fn key(this: &R2Object) -> String;
34    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = version)]
35    pub fn version(this: &R2Object) -> String;
36    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = size)]
37    pub fn size(this: &R2Object) -> u32;
38    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = etag)]
39    pub fn etag(this: &R2Object) -> String;
40    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = httpEtag)]
41    pub fn http_etag(this: &R2Object) -> String;
42    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = uploaded)]
43    pub fn uploaded(this: &R2Object) -> ::js_sys::Date;
44    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = httpMetadata)]
45    pub fn http_metadata(this: &R2Object) -> R2HttpMetadata;
46    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = customMetadata)]
47    pub fn custom_metadata(this: &R2Object) -> Object;
48    #[wasm_bindgen(structural, method, getter, js_class=R2Object, js_name = range)]
49    pub fn range(this: &R2Object) -> R2Range;
50    #[wasm_bindgen(structural, method, js_class=R2Object, js_name = writeHttpMetadata, catch)]
51    pub fn write_http_metadata(this: &R2Object, headers: Headers) -> Result<Object, JsValue>;
52}
53
54#[wasm_bindgen]
55extern "C" {
56    #[wasm_bindgen(extends=R2Object, js_name=R2ObjectBody)]
57    #[derive(Debug, Clone, PartialEq, Eq)]
58    pub type R2ObjectBody;
59
60    #[wasm_bindgen(structural, method, getter, js_class=R2ObjectBody, js_name = body)]
61    pub fn body(this: &R2ObjectBody) -> ReadableStream;
62    #[wasm_bindgen(structural, method, getter, js_class=R2ObjectBody, js_name = bodyUsed)]
63    pub fn body_used(this: &R2ObjectBody) -> bool;
64}
65
66#[wasm_bindgen]
67extern "C" {
68    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2Objects)]
69    #[derive(Debug, Clone, PartialEq, Eq)]
70    pub type R2Objects;
71
72    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = objects)]
73    pub fn objects(this: &R2Objects) -> Vec<R2Object>;
74    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = truncated)]
75    pub fn truncated(this: &R2Objects) -> bool;
76    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = cursor)]
77    pub fn cursor(this: &R2Objects) -> Option<String>;
78    #[wasm_bindgen(structural, method, getter, js_class=R2Objects, js_name = delimitedPrefixes)]
79    pub fn delimited_prefixes(this: &R2Objects) -> Vec<JsString>;
80}
81
82#[wasm_bindgen]
83#[derive(Debug, Clone)]
84pub struct R2Range {
85    pub offset: Option<u32>,
86    pub length: Option<u32>,
87    pub suffix: Option<u32>,
88}
89
90#[wasm_bindgen]
91extern "C" {
92    #[wasm_bindgen(extends=::js_sys::Object, js_name=R2HttpMetadata)]
93    #[derive(Debug, Clone, PartialEq, Eq)]
94    pub type R2HttpMetadata;
95
96    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentType)]
97    pub fn content_type(this: &R2HttpMetadata) -> Option<String>;
98    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentLanguage)]
99    pub fn content_language(this: &R2HttpMetadata) -> Option<String>;
100    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentDisposition)]
101    pub fn content_disposition(this: &R2HttpMetadata) -> Option<String>;
102    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = contentEncoding)]
103    pub fn content_encoding(this: &R2HttpMetadata) -> Option<String>;
104    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = cacheControl)]
105    pub fn cache_control(this: &R2HttpMetadata) -> Option<String>;
106    #[wasm_bindgen(structural, method, getter, js_class=R2HttpMetadata, js_name = cacheExpiry)]
107    pub fn cache_expiry(this: &R2HttpMetadata) -> Option<::js_sys::Date>;
108}