script/dom/filesystem/
filesystem.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use script_bindings::reflector::{Reflector, reflect_dom_object_with_cx};
8
9use crate::dom::bindings::codegen::Bindings::FileSystemBinding::FileSystemMethods;
10use crate::dom::bindings::root::{Dom, DomRoot};
11use crate::dom::bindings::str::USVString;
12use crate::dom::filesystemdirectoryentry::FileSystemDirectoryEntry;
13use crate::dom::globalscope::GlobalScope;
14
15#[dom_struct]
16pub(crate) struct FileSystem {
17 reflector_: Reflector,
18 name: USVString,
19 root: Dom<FileSystemDirectoryEntry>,
20}
21
22impl FileSystem {
23 fn new_inherited(name: USVString, root: &FileSystemDirectoryEntry) -> FileSystem {
24 FileSystem {
25 reflector_: Reflector::new(),
26 name,
27 root: Dom::from_ref(root),
28 }
29 }
30
31 pub(crate) fn new(
32 cx: &mut JSContext,
33 global: &GlobalScope,
34 name: USVString,
35 root: &FileSystemDirectoryEntry,
36 ) -> DomRoot<FileSystem> {
37 reflect_dom_object_with_cx(Box::new(FileSystem::new_inherited(name, root)), global, cx)
38 }
39}
40
41impl FileSystemMethods<crate::DomTypeHolder> for FileSystem {
42 fn Name(&self) -> USVString {
44 self.name.clone()
45 }
46
47 fn Root(&self) -> DomRoot<FileSystemDirectoryEntry> {
49 DomRoot::from_ref(&self.root)
50 }
51}