11use std:: borrow:: Cow ;
22
3+ #[ cfg( not( target_os = "wasi" ) ) ]
34use crate :: browser:: BrowserHistory ;
5+ #[ cfg( not( target_os = "wasi" ) ) ]
46use crate :: hash:: HashHistory ;
57use crate :: history:: History ;
68use crate :: listener:: HistoryListener ;
@@ -13,8 +15,10 @@ use crate::{error::HistoryResult, query::ToQuery};
1315#[ derive( Clone , PartialEq , Debug ) ]
1416pub enum AnyHistory {
1517 /// A Browser History.
18+ #[ cfg( not( target_os = "wasi" ) ) ]
1619 Browser ( BrowserHistory ) ,
1720 /// A Hash History
21+ #[ cfg( not( target_os = "wasi" ) ) ]
1822 Hash ( HashHistory ) ,
1923 /// A Memory History
2024 Memory ( MemoryHistory ) ,
@@ -23,31 +27,39 @@ pub enum AnyHistory {
2327impl History for AnyHistory {
2428 fn len ( & self ) -> usize {
2529 match self {
30+ #[ cfg( not( target_os = "wasi" ) ) ]
2631 Self :: Browser ( m) => m. len ( ) ,
32+ #[ cfg( not( target_os = "wasi" ) ) ]
2733 Self :: Hash ( m) => m. len ( ) ,
2834 Self :: Memory ( m) => m. len ( ) ,
2935 }
3036 }
3137
3238 fn go ( & self , delta : isize ) {
3339 match self {
40+ #[ cfg( not( target_os = "wasi" ) ) ]
3441 Self :: Browser ( m) => m. go ( delta) ,
42+ #[ cfg( not( target_os = "wasi" ) ) ]
3543 Self :: Hash ( m) => m. go ( delta) ,
3644 Self :: Memory ( m) => m. go ( delta) ,
3745 }
3846 }
3947
4048 fn push < ' a > ( & self , route : impl Into < Cow < ' a , str > > ) {
4149 match self {
50+ #[ cfg( not( target_os = "wasi" ) ) ]
4251 Self :: Browser ( m) => m. push ( route) ,
52+ #[ cfg( not( target_os = "wasi" ) ) ]
4353 Self :: Hash ( m) => m. push ( route) ,
4454 Self :: Memory ( m) => m. push ( route) ,
4555 }
4656 }
4757
4858 fn replace < ' a > ( & self , route : impl Into < Cow < ' a , str > > ) {
4959 match self {
60+ #[ cfg( not( target_os = "wasi" ) ) ]
5061 Self :: Browser ( m) => m. replace ( route) ,
62+ #[ cfg( not( target_os = "wasi" ) ) ]
5163 Self :: Hash ( m) => m. replace ( route) ,
5264 Self :: Memory ( m) => m. replace ( route) ,
5365 }
@@ -58,7 +70,9 @@ impl History for AnyHistory {
5870 T : ' static ,
5971 {
6072 match self {
73+ #[ cfg( not( target_os = "wasi" ) ) ]
6174 Self :: Browser ( m) => m. push_with_state ( route, state) ,
75+ #[ cfg( not( target_os = "wasi" ) ) ]
6276 Self :: Hash ( m) => m. push_with_state ( route, state) ,
6377 Self :: Memory ( m) => m. push_with_state ( route, state) ,
6478 }
@@ -69,7 +83,9 @@ impl History for AnyHistory {
6983 T : ' static ,
7084 {
7185 match self {
86+ #[ cfg( not( target_os = "wasi" ) ) ]
7287 Self :: Browser ( m) => m. replace_with_state ( route, state) ,
88+ #[ cfg( not( target_os = "wasi" ) ) ]
7389 Self :: Hash ( m) => m. replace_with_state ( route, state) ,
7490 Self :: Memory ( m) => m. replace_with_state ( route, state) ,
7591 }
@@ -85,7 +101,9 @@ impl History for AnyHistory {
85101 Q : ToQuery ,
86102 {
87103 match self {
104+ #[ cfg( not( target_os = "wasi" ) ) ]
88105 Self :: Browser ( m) => m. push_with_query ( route, query) ,
106+ #[ cfg( not( target_os = "wasi" ) ) ]
89107 Self :: Hash ( m) => m. push_with_query ( route, query) ,
90108 Self :: Memory ( m) => m. push_with_query ( route, query) ,
91109 }
@@ -100,7 +118,9 @@ impl History for AnyHistory {
100118 Q : ToQuery ,
101119 {
102120 match self {
121+ #[ cfg( not( target_os = "wasi" ) ) ]
103122 Self :: Browser ( m) => m. replace_with_query ( route, query) ,
123+ #[ cfg( not( target_os = "wasi" ) ) ]
104124 Self :: Hash ( m) => m. replace_with_query ( route, query) ,
105125 Self :: Memory ( m) => m. replace_with_query ( route, query) ,
106126 }
@@ -118,7 +138,9 @@ impl History for AnyHistory {
118138 T : ' static ,
119139 {
120140 match self {
141+ #[ cfg( not( target_os = "wasi" ) ) ]
121142 Self :: Browser ( m) => m. push_with_query_and_state ( route, query, state) ,
143+ #[ cfg( not( target_os = "wasi" ) ) ]
122144 Self :: Hash ( m) => m. push_with_query_and_state ( route, query, state) ,
123145 Self :: Memory ( m) => m. push_with_query_and_state ( route, query, state) ,
124146 }
@@ -136,7 +158,9 @@ impl History for AnyHistory {
136158 T : ' static ,
137159 {
138160 match self {
161+ #[ cfg( not( target_os = "wasi" ) ) ]
139162 Self :: Browser ( m) => m. replace_with_query_and_state ( route, query, state) ,
163+ #[ cfg( not( target_os = "wasi" ) ) ]
140164 Self :: Hash ( m) => m. replace_with_query_and_state ( route, query, state) ,
141165 Self :: Memory ( m) => m. replace_with_query_and_state ( route, query, state) ,
142166 }
@@ -147,27 +171,33 @@ impl History for AnyHistory {
147171 CB : Fn ( ) + ' static ,
148172 {
149173 match self {
174+ #[ cfg( not( target_os = "wasi" ) ) ]
150175 Self :: Browser ( m) => m. listen ( callback) ,
176+ #[ cfg( not( target_os = "wasi" ) ) ]
151177 Self :: Hash ( m) => m. listen ( callback) ,
152178 Self :: Memory ( m) => m. listen ( callback) ,
153179 }
154180 }
155181
156182 fn location ( & self ) -> Location {
157183 match self {
184+ #[ cfg( not( target_os = "wasi" ) ) ]
158185 Self :: Browser ( m) => m. location ( ) ,
186+ #[ cfg( not( target_os = "wasi" ) ) ]
159187 Self :: Hash ( m) => m. location ( ) ,
160188 Self :: Memory ( m) => m. location ( ) ,
161189 }
162190 }
163191}
164192
193+ #[ cfg( not( target_os = "wasi" ) ) ]
165194impl From < BrowserHistory > for AnyHistory {
166195 fn from ( m : BrowserHistory ) -> AnyHistory {
167196 AnyHistory :: Browser ( m)
168197 }
169198}
170199
200+ #[ cfg( not( target_os = "wasi" ) ) ]
171201impl From < HashHistory > for AnyHistory {
172202 fn from ( m : HashHistory ) -> AnyHistory {
173203 AnyHistory :: Hash ( m)
0 commit comments