File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,6 @@ use std::fs::Metadata;
33use std:: io;
44use std:: path:: { Path , PathBuf } ;
55
6- use cfg_if:: cfg_if;
7-
8- use crate :: io:: AsyncRead ;
96use crate :: rt;
107
118pub struct ReadDir {
@@ -98,17 +95,21 @@ impl ReadDir {
9895 }
9996}
10097
101- pub async fn open_file < P : AsRef < Path > > ( path : P ) -> Result < impl AsyncRead + Unpin , io:: Error > {
102- cfg_if ! {
103- if #[ cfg( all( feature = "_rt-async-io" , not( feature = "_rt-tokio" ) ) ) ] {
104- async_fs:: File :: open( path) . await
105- } else {
106- #[ cfg( feature = "_rt-tokio" ) ]
107- if rt:: rt_tokio:: available( ) {
108- return tokio:: fs:: File :: open( path) . await ;
109- }
110-
111- rt:: missing_rt( path)
112- }
98+ #[ cfg( feature = "_rt-tokio" ) ]
99+ pub async fn open_file < P : AsRef < Path > > ( path : P ) -> Result < tokio:: fs:: File , io:: Error > {
100+ if rt:: rt_tokio:: available ( ) {
101+ return tokio:: fs:: File :: open ( path) . await ;
113102 }
103+
104+ rt:: missing_rt ( path) ;
105+ }
106+
107+ #[ cfg( all( feature = "_rt-async-io" , not( feature = "_rt-tokio" ) ) ) ]
108+ pub async fn open_file < P : AsRef < Path > > ( path : P ) -> Result < async_fs:: File , io:: Error > {
109+ async_fs:: File :: open ( path) . await
110+ }
111+
112+ #[ cfg( all( not( feature = "_rt-async-io" ) , not( feature = "_rt-tokio" ) ) ) ]
113+ pub async fn open_file < P : AsRef < Path > > ( path : P ) -> Result < futures_util:: io:: Empty , io:: Error > {
114+ rt:: missing_rt ( path)
114115}
You can’t perform that action at this time.
0 commit comments