1use dom_struct::dom_struct;
5use script_bindings::codegen::GenericBindings::IDBIndexBinding::IDBIndexMethods;
6use script_bindings::str::DOMString;
7
8use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
9use crate::dom::bindings::root::DomRoot;
10use crate::dom::globalscope::GlobalScope;
11use crate::dom::idbobjectstore::IDBObjectStore;
12use crate::script_runtime::CanGc;
13
14#[dom_struct]
15pub(crate) struct IDBIndex {
16 reflector_: Reflector,
17 object_store: DomRoot<IDBObjectStore>,
18 name: DOMString,
19 multi_entry: bool,
20 unique: bool,
21}
22
23impl IDBIndex {
24 pub fn new_inherited(
25 object_store: DomRoot<IDBObjectStore>,
26 name: DOMString,
27 multi_entry: bool,
28 unique: bool,
29 ) -> IDBIndex {
30 IDBIndex {
31 reflector_: Reflector::new(),
32 object_store,
33 name,
34 multi_entry,
35 unique,
36 }
37 }
38
39 #[expect(dead_code)]
40 pub fn new(
41 global: &GlobalScope,
42 object_store: DomRoot<IDBObjectStore>,
43 name: DOMString,
44 multi_entry: bool,
45 unique: bool,
46 can_gc: CanGc,
47 ) -> DomRoot<IDBIndex> {
48 reflect_dom_object(
49 Box::new(IDBIndex::new_inherited(
50 object_store,
51 name,
52 multi_entry,
53 unique,
54 )),
55 global,
56 can_gc,
57 )
58 }
59}
60
61impl IDBIndexMethods<crate::DomTypeHolder> for IDBIndex {
62 fn ObjectStore(&self) -> DomRoot<IDBObjectStore> {
64 self.object_store.clone()
65 }
66
67 fn MultiEntry(&self) -> bool {
69 self.multi_entry
70 }
71
72 fn Unique(&self) -> bool {
74 self.unique
75 }
76}