@@ -37,33 +37,58 @@ pub mod time;
37
37
38
38
pub use command:: Command ;
39
39
pub use executor:: Executor ;
40
+ pub use platform:: * ;
40
41
pub use runtime:: Runtime ;
41
42
pub use subscription:: Subscription ;
42
43
43
- /// A boxed static future.
44
- ///
45
- /// - On native platforms, it needs a `Send` requirement.
46
- /// - On the Web platform, it does not need a `Send` requirement.
47
44
#[ cfg( not( target_arch = "wasm32" ) ) ]
48
- pub type BoxFuture < T > = futures:: future:: BoxFuture < ' static , T > ;
45
+ mod platform {
46
+ /// A boxed static future.
47
+ ///
48
+ /// - On native platforms, it needs a `Send` requirement.
49
+ /// - On the Web platform, it does not need a `Send` requirement.
50
+ pub type BoxFuture < T > = futures:: future:: BoxFuture < ' static , T > ;
49
51
50
- /// A boxed static future.
51
- ///
52
- /// - On native platforms, it needs a `Send` requirement.
53
- /// - On the Web platform, it does not need a `Send` requirement.
54
- #[ cfg( target_arch = "wasm32" ) ]
55
- pub type BoxFuture < T > = futures:: future:: LocalBoxFuture < ' static , T > ;
52
+ /// A boxed static stream.
53
+ ///
54
+ /// - On native platforms, it needs a `Send` requirement.
55
+ /// - On the Web platform, it does not need a `Send` requirement.
56
+ pub type BoxStream < T > = futures:: stream:: BoxStream < ' static , T > ;
56
57
57
- /// A boxed static stream.
58
- ///
59
- /// - On native platforms, it needs a `Send` requirement.
60
- /// - On the Web platform, it does not need a `Send` requirement.
61
- #[ cfg( not( target_arch = "wasm32" ) ) ]
62
- pub type BoxStream < T > = futures:: stream:: BoxStream < ' static , T > ;
58
+ /// Boxes a stream.
59
+ ///
60
+ /// - On native platforms, it needs a `Send` requirement.
61
+ /// - On the Web platform, it does not need a `Send` requirement.
62
+ pub fn boxed_stream < T , S > ( stream : S ) -> BoxStream < T >
63
+ where
64
+ S : futures:: Stream < Item = T > + Send + ' static ,
65
+ {
66
+ futures:: stream:: StreamExt :: boxed ( stream)
67
+ }
68
+ }
63
69
64
- /// A boxed static stream.
65
- ///
66
- /// - On native platforms, it needs a `Send` requirement.
67
- /// - On the Web platform, it does not need a `Send` requirement.
68
70
#[ cfg( target_arch = "wasm32" ) ]
69
- pub type BoxStream < T > = futures:: stream:: LocalBoxStream < ' static , T > ;
71
+ mod platform {
72
+ /// A boxed static future.
73
+ ///
74
+ /// - On native platforms, it needs a `Send` requirement.
75
+ /// - On the Web platform, it does not need a `Send` requirement.
76
+ pub type BoxFuture < T > = futures:: future:: LocalBoxFuture < ' static , T > ;
77
+
78
+ /// A boxed static stream.
79
+ ///
80
+ /// - On native platforms, it needs a `Send` requirement.
81
+ /// - On the Web platform, it does not need a `Send` requirement.
82
+ pub type BoxStream < T > = futures:: stream:: LocalBoxStream < ' static , T > ;
83
+
84
+ /// Boxes a stream.
85
+ ///
86
+ /// - On native platforms, it needs a `Send` requirement.
87
+ /// - On the Web platform, it does not need a `Send` requirement.
88
+ pub fn boxed_stream < T , S > ( stream : S ) -> BoxStream < T >
89
+ where
90
+ S : futures:: Stream < Item = T > + ' static ,
91
+ {
92
+ futures:: stream:: StreamExt :: boxed_local ( stream)
93
+ }
94
+ }
0 commit comments