script/dom/indexeddb/
idbcursorwithvalue.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use js::rust::MutableHandleValue;
8use script_bindings::reflector::reflect_dom_object;
9use storage_traits::indexeddb::IndexedDBKeyRange;
10
11use crate::dom::bindings::codegen::Bindings::IDBCursorBinding::IDBCursorDirection;
12use crate::dom::bindings::codegen::Bindings::IDBCursorWithValueBinding::IDBCursorWithValueMethods;
13use crate::dom::bindings::root::DomRoot;
14use crate::dom::globalscope::GlobalScope;
15use crate::dom::indexeddb::idbcursor::{IDBCursor, ObjectStoreOrIndex};
16use crate::dom::indexeddb::idbtransaction::IDBTransaction;
17
18#[dom_struct]
19pub(crate) struct IDBCursorWithValue {
20 cursor: IDBCursor,
21}
22
23impl IDBCursorWithValue {
24 #[cfg_attr(crown, expect(crown::unrooted_must_root))]
25 fn new_inherited(
26 transaction: &IDBTransaction,
27 direction: IDBCursorDirection,
28 got_value: bool,
29 source: ObjectStoreOrIndex,
30 range: IndexedDBKeyRange,
31 key_only: bool,
32 ) -> IDBCursorWithValue {
33 IDBCursorWithValue {
34 cursor: IDBCursor::new_inherited(
35 transaction,
36 direction,
37 got_value,
38 source,
39 range,
40 key_only,
41 ),
42 }
43 }
44
45 #[cfg_attr(crown, expect(crown::unrooted_must_root))]
46 #[expect(clippy::too_many_arguments)]
47 pub(crate) fn new(
48 cx: &mut JSContext,
49 global: &GlobalScope,
50 transaction: &IDBTransaction,
51 direction: IDBCursorDirection,
52 got_value: bool,
53 source: ObjectStoreOrIndex,
54 range: IndexedDBKeyRange,
55 key_only: bool,
56 ) -> DomRoot<IDBCursorWithValue> {
57 reflect_dom_object(
58 cx,
59 Box::new(IDBCursorWithValue::new_inherited(
60 transaction,
61 direction,
62 got_value,
63 source,
64 range,
65 key_only,
66 )),
67 global,
68 )
69 }
70}
71
72impl IDBCursorWithValueMethods<crate::DomTypeHolder> for IDBCursorWithValue {
73 fn Value(&self, _cx: &mut JSContext, value: MutableHandleValue) {
75 self.cursor.value(value);
76 }
77}