@@ -15,6 +15,7 @@ use thiserror::Error;
15
15
///
16
16
/// [Tokio]: https://crates.io/crates/tokio
17
17
/// [async-std]: https://crates.io/crates/async-std
18
+ #[ cfg( feature = "experimental_async_runtime" ) ]
18
19
pub trait Runtime : Clone + Send + Sync + ' static {
19
20
/// A future stream, which returns items in a previously specified interval. The item type is
20
21
/// not important.
@@ -44,13 +45,19 @@ pub trait Runtime: Clone + Send + Sync + 'static {
44
45
}
45
46
46
47
/// Runtime implementation, which works with Tokio's multi thread runtime.
47
- #[ cfg( feature = "rt-tokio" ) ]
48
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-tokio" ) ) ) ]
48
+ #[ cfg( all( feature = "experimental_async_runtime" , feature = "rt-tokio" ) ) ]
49
+ #[ cfg_attr(
50
+ docsrs,
51
+ doc( cfg( all( feature = "experimental_async_runtime" , feature = "rt-tokio" ) ) )
52
+ ) ]
49
53
#[ derive( Debug , Clone ) ]
50
54
pub struct Tokio ;
51
55
52
- #[ cfg( feature = "rt-tokio" ) ]
53
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-tokio" ) ) ) ]
56
+ #[ cfg( all( feature = "experimental_async_runtime" , feature = "rt-tokio" ) ) ]
57
+ #[ cfg_attr(
58
+ docsrs,
59
+ doc( cfg( all( feature = "experimental_async_runtime" , feature = "rt-tokio" ) ) )
60
+ ) ]
54
61
impl Runtime for Tokio {
55
62
type Interval = tokio_stream:: wrappers:: IntervalStream ;
56
63
type Delay = :: std:: pin:: Pin < Box < tokio:: time:: Sleep > > ;
@@ -71,13 +78,31 @@ impl Runtime for Tokio {
71
78
}
72
79
73
80
/// Runtime implementation, which works with Tokio's current thread runtime.
74
- #[ cfg( feature = "rt-tokio-current-thread" ) ]
75
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-tokio-current-thread" ) ) ) ]
81
+ #[ cfg( all(
82
+ feature = "experimental_async_runtime" ,
83
+ feature = "rt-tokio-current-thread"
84
+ ) ) ]
85
+ #[ cfg_attr(
86
+ docsrs,
87
+ doc( cfg( all(
88
+ feature = "experimental_async_runtime" ,
89
+ feature = "rt-tokio-current-thread"
90
+ ) ) )
91
+ ) ]
76
92
#[ derive( Debug , Clone ) ]
77
93
pub struct TokioCurrentThread ;
78
94
79
- #[ cfg( feature = "rt-tokio-current-thread" ) ]
80
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-tokio-current-thread" ) ) ) ]
95
+ #[ cfg( all(
96
+ feature = "experimental_async_runtime" ,
97
+ feature = "rt-tokio-current-thread"
98
+ ) ) ]
99
+ #[ cfg_attr(
100
+ docsrs,
101
+ doc( cfg( all(
102
+ feature = "experimental_async_runtime" ,
103
+ feature = "rt-tokio-current-thread"
104
+ ) ) )
105
+ ) ]
81
106
impl Runtime for TokioCurrentThread {
82
107
type Interval = tokio_stream:: wrappers:: IntervalStream ;
83
108
type Delay = :: std:: pin:: Pin < Box < tokio:: time:: Sleep > > ;
@@ -108,13 +133,19 @@ impl Runtime for TokioCurrentThread {
108
133
}
109
134
110
135
/// Runtime implementation, which works with async-std.
111
- #[ cfg( feature = "rt-async-std" ) ]
112
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-async-std" ) ) ) ]
136
+ #[ cfg( all( feature = "experimental_async_runtime" , feature = "rt-async-std" ) ) ]
137
+ #[ cfg_attr(
138
+ docsrs,
139
+ doc( cfg( all( feature = "experimental_async_runtime" , feature = "rt-async-std" ) ) )
140
+ ) ]
113
141
#[ derive( Debug , Clone ) ]
114
142
pub struct AsyncStd ;
115
143
116
- #[ cfg( feature = "rt-async-std" ) ]
117
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-async-std" ) ) ) ]
144
+ #[ cfg( all( feature = "experimental_async_runtime" , feature = "rt-async-std" ) ) ]
145
+ #[ cfg_attr(
146
+ docsrs,
147
+ doc( cfg( all( feature = "experimental_async_runtime" , feature = "rt-async-std" ) ) )
148
+ ) ]
118
149
impl Runtime for AsyncStd {
119
150
type Interval = async_std:: stream:: Interval ;
120
151
type Delay = BoxFuture < ' static , ( ) > ;
@@ -138,6 +169,7 @@ impl Runtime for AsyncStd {
138
169
///
139
170
/// [log]: crate::logs::BatchLogProcessor
140
171
/// [span]: crate::trace::BatchSpanProcessor
172
+ #[ cfg( feature = "experimental_async_runtime" ) ]
141
173
pub trait RuntimeChannel : Runtime {
142
174
/// A future stream to receive batch messages from channels.
143
175
type Receiver < T : Debug + Send > : Stream < Item = T > + Send ;
@@ -152,6 +184,7 @@ pub trait RuntimeChannel: Runtime {
152
184
}
153
185
154
186
/// Error returned by a [`TrySend`] implementation.
187
+ #[ cfg( feature = "experimental_async_runtime" ) ]
155
188
#[ derive( Debug , Error ) ]
156
189
pub enum TrySendError {
157
190
/// Send failed due to the channel being full.
@@ -166,6 +199,7 @@ pub enum TrySendError {
166
199
}
167
200
168
201
/// TrySend is an abstraction of `Sender` that is capable of sending messages through a reference.
202
+ #[ cfg( feature = "experimental_async_runtime" ) ]
169
203
pub trait TrySend : Sync + Send {
170
204
/// The message that will be sent.
171
205
type Message ;
@@ -176,7 +210,10 @@ pub trait TrySend: Sync + Send {
176
210
fn try_send ( & self , item : Self :: Message ) -> Result < ( ) , TrySendError > ;
177
211
}
178
212
179
- #[ cfg( any( feature = "rt-tokio" , feature = "rt-tokio-current-thread" ) ) ]
213
+ #[ cfg( all(
214
+ feature = "experimental_async_runtime" ,
215
+ any( feature = "rt-tokio" , feature = "rt-tokio-current-thread" )
216
+ ) ) ]
180
217
impl < T : Send > TrySend for tokio:: sync:: mpsc:: Sender < T > {
181
218
type Message = T ;
182
219
@@ -188,8 +225,11 @@ impl<T: Send> TrySend for tokio::sync::mpsc::Sender<T> {
188
225
}
189
226
}
190
227
191
- #[ cfg( feature = "rt-tokio" ) ]
192
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-tokio" ) ) ) ]
228
+ #[ cfg( all( feature = "experimental_async_runtime" , feature = "rt-tokio" ) ) ]
229
+ #[ cfg_attr(
230
+ docsrs,
231
+ doc( cfg( all( feature = "experimental_async_runtime" , feature = "rt-tokio" ) ) )
232
+ ) ]
193
233
impl RuntimeChannel for Tokio {
194
234
type Receiver < T : Debug + Send > = tokio_stream:: wrappers:: ReceiverStream < T > ;
195
235
type Sender < T : Debug + Send > = tokio:: sync:: mpsc:: Sender < T > ;
@@ -206,8 +246,17 @@ impl RuntimeChannel for Tokio {
206
246
}
207
247
}
208
248
209
- #[ cfg( feature = "rt-tokio-current-thread" ) ]
210
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-tokio-current-thread" ) ) ) ]
249
+ #[ cfg( all(
250
+ feature = "experimental_async_runtime" ,
251
+ feature = "rt-tokio-current-thread"
252
+ ) ) ]
253
+ #[ cfg_attr(
254
+ docsrs,
255
+ doc( cfg( all(
256
+ feature = "experimental_async_runtime" ,
257
+ feature = "rt-tokio-current-thread"
258
+ ) ) )
259
+ ) ]
211
260
impl RuntimeChannel for TokioCurrentThread {
212
261
type Receiver < T : Debug + Send > = tokio_stream:: wrappers:: ReceiverStream < T > ;
213
262
type Sender < T : Debug + Send > = tokio:: sync:: mpsc:: Sender < T > ;
@@ -224,7 +273,7 @@ impl RuntimeChannel for TokioCurrentThread {
224
273
}
225
274
}
226
275
227
- #[ cfg( feature = "rt-async-std" ) ]
276
+ #[ cfg( all ( feature = "experimental_async_runtime" , feature = " rt-async-std") ) ]
228
277
impl < T : Send > TrySend for async_std:: channel:: Sender < T > {
229
278
type Message = T ;
230
279
@@ -236,8 +285,11 @@ impl<T: Send> TrySend for async_std::channel::Sender<T> {
236
285
}
237
286
}
238
287
239
- #[ cfg( feature = "rt-async-std" ) ]
240
- #[ cfg_attr( docsrs, doc( cfg( feature = "rt-async-std" ) ) ) ]
288
+ #[ cfg( all( feature = "experimental_async_runtime" , feature = "rt-async-std" ) ) ]
289
+ #[ cfg_attr(
290
+ docsrs,
291
+ doc( cfg( all( feature = "experimental_async_runtime" , feature = "rt-async-std" ) ) )
292
+ ) ]
241
293
impl RuntimeChannel for AsyncStd {
242
294
type Receiver < T : Debug + Send > = async_std:: channel:: Receiver < T > ;
243
295
type Sender < T : Debug + Send > = async_std:: channel:: Sender < T > ;
0 commit comments