1+ #![ cfg( feature="__io__" ) ]
2+
3+ use crate :: io:: { AsyncRead , AsyncWrite } ;
4+ use crate :: sync:: RwLock ;
15use crate :: { Config , Message } ;
2- use crate :: runtime:: { AsyncRead , AsyncWrite , RwLock } ;
36use std:: { sync:: Arc , io:: Error } ;
47
58pub trait UnderlyingConnection : AsyncRead + AsyncWrite + Unpin + ' static { }
@@ -19,24 +22,11 @@ pub struct Connection<C: UnderlyingConnection> {
1922/*============================================================*/
2023 #[ inline( always) ]
2124 async fn read_closed ( __closed__ : & RwLock < bool > ) -> bool {
22- #[ cfg( feature="rt_glommio" ) ]
23- match __closed__. read ( ) . await {
24- Ok ( read) => * read,
25- Err ( _/* closed */ ) => true
26- }
27- #[ cfg( not( feature="rt_glommio" ) ) ]
2825 * __closed__. read ( ) . await
2926 }
3027 #[ inline( always) ]
3128 async fn set_closed ( __closed__ : & RwLock < bool > ) {
32- #[ cfg( feature="rt_glommio" ) ] {
33- if let Ok ( mut write) = __closed__. write ( ) . await {
34- * write = true
35- }
36- }
37- #[ cfg( not( feature="rt_glommio" ) ) ] {
38- * __closed__. write ( ) . await = true
39- }
29+ * __closed__. write ( ) . await = true
4030 }
4131
4232 const ALREADY_CLOSED_MESSAGE : & str = "\n \
@@ -333,17 +323,8 @@ pub mod split {
333323 }
334324 }
335325
336- #[ cfg( feature="__io_futures__ " ) ]
326+ #[ cfg( feature="io_futures " ) ]
337327 const _: ( /* futures-io users */ ) = {
338- #[ cfg( feature="tcpstream-only" ) ]
339- impl < ' split > Splitable < ' split > for crate :: runtime:: net:: TcpStream {
340- type ReadHalf = futures_util:: io:: ReadHalf < & ' split mut Self > ;
341- type WriteHalf = futures_util:: io:: WriteHalf < & ' split mut Self > ;
342- fn split ( & ' split mut self ) -> ( Self :: ReadHalf , Self :: WriteHalf ) {
343- AsyncRead :: split ( self )
344- }
345- }
346- #[ cfg( not( feature="tcpstream-only" ) ) ]
347328 impl < ' split , T : AsyncRead + AsyncWrite + Unpin + ' split > Splitable < ' split > for T {
348329 type ReadHalf = futures_util:: io:: ReadHalf < & ' split mut T > ;
349330 type WriteHalf = futures_util:: io:: WriteHalf < & ' split mut T > ;
@@ -353,20 +334,7 @@ pub mod split {
353334 }
354335 } ;
355336
356- #[ cfg( feature="__io_tokio__" ) ]
357- #[ cfg( feature="tcpstream-only" ) ]
358- const _: ( /* tokio::io users */ ) = {
359- /* efficient-able specialized impl for `TcpStream` */
360- impl < ' split > Splitable < ' split > for crate :: runtime:: net:: TcpStream {
361- type ReadHalf = crate :: runtime:: net:: tcp:: ReadHalf < ' split > ;
362- type WriteHalf = crate :: runtime:: net:: tcp:: WriteHalf < ' split > ;
363- fn split ( & ' split mut self ) -> ( Self :: ReadHalf , Self :: WriteHalf ) {
364- crate :: runtime:: net:: TcpStream :: split ( self )
365- }
366- }
367- } ;
368- #[ cfg( feature="__io_tokio__" ) ]
369- #[ cfg( not( feature="tcpstream-only" ) ) ]
337+ #[ cfg( feature="io_tokio" ) ]
370338 const _: ( /* tokio::io users */ ) = {
371339 impl < ' split , T : AsyncRead + AsyncWrite + Unpin + ' split > Splitable < ' split > for T {
372340 type ReadHalf = TokioIoReadHalf < ' split , T > ;
@@ -494,15 +462,3 @@ pub mod split {
494462 }
495463 }
496464}
497-
498- #[ cfg( test) ]
499- mod tests {
500- use super :: * ;
501-
502- #[ cfg( feature="__runtime__" ) ]
503- #[ test]
504- fn test_impl_splitable ( ) {
505- fn assert_impl_splitable < T : split:: Splitable < ' static > > ( ) { }
506- assert_impl_splitable :: < crate :: runtime:: net:: TcpStream > ( ) ;
507- }
508- }
0 commit comments