1 use webcore::value::Reference;
2 use webcore::try_from::TryInto;
3 use webapi::blob::{IBlob, Blob};
4 
5 /// The File interface provides information about files and allows JavaScript
6 /// in a web page to access their content.
7 ///
8 /// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/File)
9 // https://w3c.github.io/FileAPI/#dfn-file
10 #[derive(Clone, Debug, PartialEq, Eq, ReferenceType)]
11 #[reference(instance_of = "File")]
12 #[reference(subclass_of(Blob))]
13 pub struct File( pub(crate) Reference );
14 
15 impl IBlob for File {}
16 
17 impl File {
18     /// Returns the name of the file referenced by the `File` object.
19     ///
20     /// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/File/name)
21     // https://w3c.github.io/FileAPI/#ref-for-dfn-name%E2%91%A0
name( &self ) -> String22     pub fn name( &self ) -> String {
23         js!( return @{self}.name; ).try_into().unwrap()
24     }
25 }
26