1
1
use std:: borrow:: Cow ;
2
2
3
+ #[ cfg( not( target_os = "wasi" ) ) ]
3
4
use crate :: browser:: BrowserHistory ;
5
+ #[ cfg( not( target_os = "wasi" ) ) ]
4
6
use crate :: hash:: HashHistory ;
5
7
use crate :: history:: History ;
6
8
use crate :: listener:: HistoryListener ;
@@ -13,8 +15,10 @@ use crate::{error::HistoryResult, query::ToQuery};
13
15
#[ derive( Clone , PartialEq , Debug ) ]
14
16
pub enum AnyHistory {
15
17
/// A Browser History.
18
+ #[ cfg( not( target_os = "wasi" ) ) ]
16
19
Browser ( BrowserHistory ) ,
17
20
/// A Hash History
21
+ #[ cfg( not( target_os = "wasi" ) ) ]
18
22
Hash ( HashHistory ) ,
19
23
/// A Memory History
20
24
Memory ( MemoryHistory ) ,
@@ -23,31 +27,39 @@ pub enum AnyHistory {
23
27
impl History for AnyHistory {
24
28
fn len ( & self ) -> usize {
25
29
match self {
30
+ #[ cfg( not( target_os = "wasi" ) ) ]
26
31
Self :: Browser ( m) => m. len ( ) ,
32
+ #[ cfg( not( target_os = "wasi" ) ) ]
27
33
Self :: Hash ( m) => m. len ( ) ,
28
34
Self :: Memory ( m) => m. len ( ) ,
29
35
}
30
36
}
31
37
32
38
fn go ( & self , delta : isize ) {
33
39
match self {
40
+ #[ cfg( not( target_os = "wasi" ) ) ]
34
41
Self :: Browser ( m) => m. go ( delta) ,
42
+ #[ cfg( not( target_os = "wasi" ) ) ]
35
43
Self :: Hash ( m) => m. go ( delta) ,
36
44
Self :: Memory ( m) => m. go ( delta) ,
37
45
}
38
46
}
39
47
40
48
fn push < ' a > ( & self , route : impl Into < Cow < ' a , str > > ) {
41
49
match self {
50
+ #[ cfg( not( target_os = "wasi" ) ) ]
42
51
Self :: Browser ( m) => m. push ( route) ,
52
+ #[ cfg( not( target_os = "wasi" ) ) ]
43
53
Self :: Hash ( m) => m. push ( route) ,
44
54
Self :: Memory ( m) => m. push ( route) ,
45
55
}
46
56
}
47
57
48
58
fn replace < ' a > ( & self , route : impl Into < Cow < ' a , str > > ) {
49
59
match self {
60
+ #[ cfg( not( target_os = "wasi" ) ) ]
50
61
Self :: Browser ( m) => m. replace ( route) ,
62
+ #[ cfg( not( target_os = "wasi" ) ) ]
51
63
Self :: Hash ( m) => m. replace ( route) ,
52
64
Self :: Memory ( m) => m. replace ( route) ,
53
65
}
@@ -58,7 +70,9 @@ impl History for AnyHistory {
58
70
T : ' static ,
59
71
{
60
72
match self {
73
+ #[ cfg( not( target_os = "wasi" ) ) ]
61
74
Self :: Browser ( m) => m. push_with_state ( route, state) ,
75
+ #[ cfg( not( target_os = "wasi" ) ) ]
62
76
Self :: Hash ( m) => m. push_with_state ( route, state) ,
63
77
Self :: Memory ( m) => m. push_with_state ( route, state) ,
64
78
}
@@ -69,7 +83,9 @@ impl History for AnyHistory {
69
83
T : ' static ,
70
84
{
71
85
match self {
86
+ #[ cfg( not( target_os = "wasi" ) ) ]
72
87
Self :: Browser ( m) => m. replace_with_state ( route, state) ,
88
+ #[ cfg( not( target_os = "wasi" ) ) ]
73
89
Self :: Hash ( m) => m. replace_with_state ( route, state) ,
74
90
Self :: Memory ( m) => m. replace_with_state ( route, state) ,
75
91
}
@@ -85,7 +101,9 @@ impl History for AnyHistory {
85
101
Q : ToQuery ,
86
102
{
87
103
match self {
104
+ #[ cfg( not( target_os = "wasi" ) ) ]
88
105
Self :: Browser ( m) => m. push_with_query ( route, query) ,
106
+ #[ cfg( not( target_os = "wasi" ) ) ]
89
107
Self :: Hash ( m) => m. push_with_query ( route, query) ,
90
108
Self :: Memory ( m) => m. push_with_query ( route, query) ,
91
109
}
@@ -100,7 +118,9 @@ impl History for AnyHistory {
100
118
Q : ToQuery ,
101
119
{
102
120
match self {
121
+ #[ cfg( not( target_os = "wasi" ) ) ]
103
122
Self :: Browser ( m) => m. replace_with_query ( route, query) ,
123
+ #[ cfg( not( target_os = "wasi" ) ) ]
104
124
Self :: Hash ( m) => m. replace_with_query ( route, query) ,
105
125
Self :: Memory ( m) => m. replace_with_query ( route, query) ,
106
126
}
@@ -118,7 +138,9 @@ impl History for AnyHistory {
118
138
T : ' static ,
119
139
{
120
140
match self {
141
+ #[ cfg( not( target_os = "wasi" ) ) ]
121
142
Self :: Browser ( m) => m. push_with_query_and_state ( route, query, state) ,
143
+ #[ cfg( not( target_os = "wasi" ) ) ]
122
144
Self :: Hash ( m) => m. push_with_query_and_state ( route, query, state) ,
123
145
Self :: Memory ( m) => m. push_with_query_and_state ( route, query, state) ,
124
146
}
@@ -136,7 +158,9 @@ impl History for AnyHistory {
136
158
T : ' static ,
137
159
{
138
160
match self {
161
+ #[ cfg( not( target_os = "wasi" ) ) ]
139
162
Self :: Browser ( m) => m. replace_with_query_and_state ( route, query, state) ,
163
+ #[ cfg( not( target_os = "wasi" ) ) ]
140
164
Self :: Hash ( m) => m. replace_with_query_and_state ( route, query, state) ,
141
165
Self :: Memory ( m) => m. replace_with_query_and_state ( route, query, state) ,
142
166
}
@@ -147,27 +171,33 @@ impl History for AnyHistory {
147
171
CB : Fn ( ) + ' static ,
148
172
{
149
173
match self {
174
+ #[ cfg( not( target_os = "wasi" ) ) ]
150
175
Self :: Browser ( m) => m. listen ( callback) ,
176
+ #[ cfg( not( target_os = "wasi" ) ) ]
151
177
Self :: Hash ( m) => m. listen ( callback) ,
152
178
Self :: Memory ( m) => m. listen ( callback) ,
153
179
}
154
180
}
155
181
156
182
fn location ( & self ) -> Location {
157
183
match self {
184
+ #[ cfg( not( target_os = "wasi" ) ) ]
158
185
Self :: Browser ( m) => m. location ( ) ,
186
+ #[ cfg( not( target_os = "wasi" ) ) ]
159
187
Self :: Hash ( m) => m. location ( ) ,
160
188
Self :: Memory ( m) => m. location ( ) ,
161
189
}
162
190
}
163
191
}
164
192
193
+ #[ cfg( not( target_os = "wasi" ) ) ]
165
194
impl From < BrowserHistory > for AnyHistory {
166
195
fn from ( m : BrowserHistory ) -> AnyHistory {
167
196
AnyHistory :: Browser ( m)
168
197
}
169
198
}
170
199
200
+ #[ cfg( not( target_os = "wasi" ) ) ]
171
201
impl From < HashHistory > for AnyHistory {
172
202
fn from ( m : HashHistory ) -> AnyHistory {
173
203
AnyHistory :: Hash ( m)
0 commit comments