1use wasm_bindgen::prelude::*;
2#[wasm_bindgen]
3extern "C" {
4 #[wasm_bindgen (extends = web_sys::Blob , extends = ::js_sys::Object , js_name = File , typescript_type = "File")]
5 #[derive(Debug, Clone, PartialEq, Eq)]
6 #[doc = "The `File` class."]
7 pub type File;
8
9 #[wasm_bindgen (structural , method , getter , js_class = "File" , js_name = name)]
10 #[doc = "Getter for the `name` field of this object."]
11 pub fn name(this: &File) -> String;
12
13 #[wasm_bindgen (structural , method , getter , js_class = "File" , js_name = lastModified)]
14 #[doc = "Getter for the `lastModified` field of this object."]
15 pub fn last_modified(this: &File) -> f64;
16
17 # [wasm_bindgen (method , structural , js_class = "File" , js_name = arrayBuffer)]
18 #[doc = "The `arrayBuffer()` method."]
19 pub fn array_buffer(this: &File) -> ::js_sys::Promise;
20
21 #[wasm_bindgen(catch, constructor, js_class = "File")]
22 #[doc = "The `new File(..)` constructor, creating a new instance of `File`."]
23 pub fn new_with_u8_array_sequence(
24 file_bits: &::wasm_bindgen::JsValue,
25 file_name: &str,
26 ) -> Result<File, JsValue>;
27
28 #[wasm_bindgen(catch, constructor, js_class = "File")]
29 #[doc = "The `new File(..)` constructor, creating a new instance of `File`."]
30 pub fn new_with_u8_array_sequence_and_options(
31 file_bits: &::wasm_bindgen::JsValue,
32 file_name: &str,
33 options: &FilePropertyBag,
34 ) -> Result<File, JsValue>;
35}
36
37#[wasm_bindgen]
38extern "C" {
39 # [wasm_bindgen (extends = ::js_sys::Object , js_name = FilePropertyBag)]
40 #[derive(Debug, Clone, PartialEq, Eq)]
41 #[doc = "The `FilePropertyBag` dictionary."]
42 pub type FilePropertyBag;
43}
44impl FilePropertyBag {
45 #[doc = "Construct a new `FilePropertyBag`."]
46 pub fn new() -> Self {
47 ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new())
48 }
49
50 #[doc = "Change the `lastModified` field of this object."]
51 pub fn last_modified(&mut self, val: f64) -> &mut Self {
52 let r = ::js_sys::Reflect::set(
53 self.as_ref(),
54 &JsValue::from("lastModified"),
55 &JsValue::from(val),
56 );
57 debug_assert!(
58 r.is_ok(),
59 "setting properties should never fail on our dictionary objects"
60 );
61 let _ = r;
62 self
63 }
64
65 #[doc = "Change the `type` field of this object."]
66 pub fn type_(&mut self, val: &str) -> &mut Self {
67 let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val));
68 debug_assert!(
69 r.is_ok(),
70 "setting properties should never fail on our dictionary objects"
71 );
72 let _ = r;
73 self
74 }
75}
76impl Default for FilePropertyBag {
77 fn default() -> Self {
78 Self::new()
79 }
80}