@@ -5,7 +5,7 @@ use cap_tempfile::{ambient_authority, tempdir, TempDir};
5
5
#[ cfg( not( target_os = "wasi" ) ) ]
6
6
use io_streams:: StreamDuplexer ;
7
7
use io_streams:: { StreamReader , StreamWriter } ;
8
- use std:: io:: { self , copy, Read , Write } ;
8
+ use std:: io:: { copy, Read , Write } ;
9
9
#[ cfg( all( not( target_os = "wasi" ) , feature = "socketpair" ) ) ]
10
10
use { socketpair:: SocketpairStream , std:: str} ;
11
11
@@ -155,7 +155,7 @@ fn test_null_duplex() -> anyhow::Result<()> {
155
155
#[ test]
156
156
fn test_socketed_thread_func ( ) -> anyhow:: Result < ( ) > {
157
157
let mut thread = StreamDuplexer :: socketed_thread_func ( Box :: new (
158
- |mut stream : SocketpairStream | -> io:: Result < SocketpairStream > {
158
+ |mut stream : SocketpairStream | -> std :: io:: Result < SocketpairStream > {
159
159
let mut buf = [ 0_u8 ; 4096 ] ;
160
160
let n = stream. read ( & mut buf) ?;
161
161
assert_eq ! ( str :: from_utf8( & buf[ ..n] ) . unwrap( ) , "hello world\n " ) ;
@@ -182,10 +182,12 @@ fn test_socketed_thread_func() -> anyhow::Result<()> {
182
182
Ok ( ( ) )
183
183
}
184
184
185
+ #[ cfg( all( not( target_os = "wasi" ) , feature = "socketpair" ) ) ]
185
186
struct Mock ( bool ) ;
186
187
188
+ #[ cfg( all( not( target_os = "wasi" ) , feature = "socketpair" ) ) ]
187
189
impl Read for Mock {
188
- fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
190
+ fn read ( & mut self , buf : & mut [ u8 ] ) -> std :: io:: Result < usize > {
189
191
assert ! ( !self . 0 ) ;
190
192
self . 0 = true ;
191
193
assert ! ( !buf. is_empty( ) ) ;
@@ -195,21 +197,23 @@ impl Read for Mock {
195
197
}
196
198
}
197
199
200
+ #[ cfg( all( not( target_os = "wasi" ) , feature = "socketpair" ) ) ]
198
201
impl Write for Mock {
199
- fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
202
+ fn write ( & mut self , buf : & [ u8 ] ) -> std :: io:: Result < usize > {
200
203
assert ! ( self . 0 ) ;
201
204
self . 0 = false ;
202
205
assert_eq ! ( buf, & vec![ 0xcd_u8 ; buf. len( ) ] [ ..] ) ;
203
206
Ok ( buf. len ( ) )
204
207
}
205
208
206
- fn flush ( & mut self ) -> io:: Result < ( ) > {
209
+ fn flush ( & mut self ) -> std :: io:: Result < ( ) > {
207
210
Ok ( ( ) )
208
211
}
209
212
}
210
213
214
+ #[ cfg( all( not( target_os = "wasi" ) , feature = "socketpair" ) ) ]
211
215
impl system_interface:: io:: ReadReady for Mock {
212
- fn num_ready_bytes ( & self ) -> io:: Result < u64 > {
216
+ fn num_ready_bytes ( & self ) -> std :: io:: Result < u64 > {
213
217
if self . 0 {
214
218
Ok ( 0 )
215
219
} else {
@@ -218,6 +222,7 @@ impl system_interface::io::ReadReady for Mock {
218
222
}
219
223
}
220
224
225
+ #[ cfg( all( not( target_os = "wasi" ) , feature = "socketpair" ) ) ]
221
226
impl duplex:: Duplex for Mock { }
222
227
223
228
#[ cfg( all( not( target_os = "wasi" ) , feature = "socketpair" ) ) ]
0 commit comments