1
1
use super :: super :: traits:: * ;
2
- use crate :: { cursor:: CursorSys , error:: UnexpectedDataError } ;
2
+ use crate :: error:: UnexpectedDataError ;
3
+ use cfg_if:: cfg_if;
3
4
use std:: task:: { Context , Poll } ;
4
5
use tokio:: sync:: mpsc;
5
6
use wasm_bindgen:: prelude:: * ;
@@ -11,7 +12,8 @@ pub enum EventTargetResult {
11
12
/// the event.target.result was null
12
13
Null ,
13
14
/// the event.target.result was a [`web_sys::IdbCursor`] instance
14
- Cursor ( CursorSys ) ,
15
+ #[ cfg( feature = "cursors" ) ]
16
+ Cursor ( crate :: cursor:: CursorSys ) ,
15
17
/// the event.target.result was not null
16
18
NotNull ,
17
19
}
@@ -37,10 +39,18 @@ impl Listeners {
37
39
38
40
let _ = tx. try_send ( match non_null_result {
39
41
None => EventTargetResult :: Null ,
40
- Some ( val) => match val. dyn_into :: < CursorSys > ( ) {
41
- Ok ( cursor) => EventTargetResult :: Cursor ( cursor) ,
42
- Err ( _) => EventTargetResult :: NotNull ,
43
- } ,
42
+ Some ( val) => {
43
+ cfg_if ! {
44
+ if #[ cfg( feature = "cursors" ) ] {
45
+ match val. dyn_into:: <crate :: cursor:: CursorSys >( ) {
46
+ Ok ( cursor) => EventTargetResult :: Cursor ( cursor) ,
47
+ Err ( _) => EventTargetResult :: NotNull ,
48
+ }
49
+ } else {
50
+ EventTargetResult :: NotNull
51
+ }
52
+ }
53
+ }
44
54
} ) ;
45
55
} ) ) ;
46
56
0 commit comments