@@ -15,6 +15,7 @@ use thiserror::Error;
1515///
1616/// [Tokio]: https://crates.io/crates/tokio
1717/// [async-std]: https://crates.io/crates/async-std
18+ #[ cfg( feature = "experimental_async_runtime" ) ]
1819pub trait Runtime : Clone + Send + Sync + ' static {
1920 /// A future stream, which returns items in a previously specified interval. The item type is
2021 /// not important.
@@ -44,13 +45,19 @@ pub trait Runtime: Clone + Send + Sync + 'static {
4445}
4546
4647/// 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+ ) ]
4953#[ derive( Debug , Clone ) ]
5054pub struct Tokio ;
5155
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+ ) ]
5461impl Runtime for Tokio {
5562 type Interval = tokio_stream:: wrappers:: IntervalStream ;
5663 type Delay = :: std:: pin:: Pin < Box < tokio:: time:: Sleep > > ;
@@ -71,13 +78,31 @@ impl Runtime for Tokio {
7178}
7279
7380/// 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+ ) ]
7692#[ derive( Debug , Clone ) ]
7793pub struct TokioCurrentThread ;
7894
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+ ) ]
81106impl Runtime for TokioCurrentThread {
82107 type Interval = tokio_stream:: wrappers:: IntervalStream ;
83108 type Delay = :: std:: pin:: Pin < Box < tokio:: time:: Sleep > > ;
@@ -108,13 +133,19 @@ impl Runtime for TokioCurrentThread {
108133}
109134
110135/// 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+ ) ]
113141#[ derive( Debug , Clone ) ]
114142pub struct AsyncStd ;
115143
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+ ) ]
118149impl Runtime for AsyncStd {
119150 type Interval = async_std:: stream:: Interval ;
120151 type Delay = BoxFuture < ' static , ( ) > ;
@@ -138,6 +169,7 @@ impl Runtime for AsyncStd {
138169///
139170/// [log]: crate::logs::BatchLogProcessor
140171/// [span]: crate::trace::BatchSpanProcessor
172+ #[ cfg( feature = "experimental_async_runtime" ) ]
141173pub trait RuntimeChannel : Runtime {
142174 /// A future stream to receive batch messages from channels.
143175 type Receiver < T : Debug + Send > : Stream < Item = T > + Send ;
@@ -152,6 +184,7 @@ pub trait RuntimeChannel: Runtime {
152184}
153185
154186/// Error returned by a [`TrySend`] implementation.
187+ #[ cfg( feature = "experimental_async_runtime" ) ]
155188#[ derive( Debug , Error ) ]
156189pub enum TrySendError {
157190 /// Send failed due to the channel being full.
@@ -166,6 +199,7 @@ pub enum TrySendError {
166199}
167200
168201/// TrySend is an abstraction of `Sender` that is capable of sending messages through a reference.
202+ #[ cfg( feature = "experimental_async_runtime" ) ]
169203pub trait TrySend : Sync + Send {
170204 /// The message that will be sent.
171205 type Message ;
@@ -176,7 +210,10 @@ pub trait TrySend: Sync + Send {
176210 fn try_send ( & self , item : Self :: Message ) -> Result < ( ) , TrySendError > ;
177211}
178212
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+ ) ) ]
180217impl < T : Send > TrySend for tokio:: sync:: mpsc:: Sender < T > {
181218 type Message = T ;
182219
@@ -188,8 +225,11 @@ impl<T: Send> TrySend for tokio::sync::mpsc::Sender<T> {
188225 }
189226}
190227
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+ ) ]
193233impl RuntimeChannel for Tokio {
194234 type Receiver < T : Debug + Send > = tokio_stream:: wrappers:: ReceiverStream < T > ;
195235 type Sender < T : Debug + Send > = tokio:: sync:: mpsc:: Sender < T > ;
@@ -206,8 +246,17 @@ impl RuntimeChannel for Tokio {
206246 }
207247}
208248
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+ ) ]
211260impl RuntimeChannel for TokioCurrentThread {
212261 type Receiver < T : Debug + Send > = tokio_stream:: wrappers:: ReceiverStream < T > ;
213262 type Sender < T : Debug + Send > = tokio:: sync:: mpsc:: Sender < T > ;
@@ -224,7 +273,7 @@ impl RuntimeChannel for TokioCurrentThread {
224273 }
225274}
226275
227- #[ cfg( feature = "rt-async-std" ) ]
276+ #[ cfg( all ( feature = "experimental_async_runtime" , feature = " rt-async-std") ) ]
228277impl < T : Send > TrySend for async_std:: channel:: Sender < T > {
229278 type Message = T ;
230279
@@ -236,8 +285,11 @@ impl<T: Send> TrySend for async_std::channel::Sender<T> {
236285 }
237286}
238287
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+ ) ]
241293impl RuntimeChannel for AsyncStd {
242294 type Receiver < T : Debug + Send > = async_std:: channel:: Receiver < T > ;
243295 type Sender < T : Debug + Send > = async_std:: channel:: Sender < T > ;
0 commit comments