22
33use super :: hermit_abi;
44use crate :: cmp;
5- use crate :: io:: { self , IoSlice , IoSliceMut , Read } ;
5+ use crate :: io:: { self , IoSlice , IoSliceMut } ;
66use crate :: os:: hermit:: io:: { FromRawFd , OwnedFd , RawFd , * } ;
7- use crate :: sys:: { cvt, unsupported } ;
7+ use crate :: sys:: cvt;
88use crate :: sys_common:: { AsInner , FromInner , IntoInner } ;
99
1010const fn max_iov ( ) -> usize {
@@ -39,11 +39,6 @@ impl FileDesc {
3939 true
4040 }
4141
42- pub fn read_to_end ( & self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
43- let mut me = self ;
44- ( & mut me) . read_to_end ( buf)
45- }
46-
4742 pub fn write ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
4843 let result =
4944 cvt ( unsafe { hermit_abi:: write ( self . fd . as_raw_fd ( ) , buf. as_ptr ( ) , buf. len ( ) ) } ) ?;
@@ -66,37 +61,12 @@ impl FileDesc {
6661 true
6762 }
6863
69- pub fn duplicate ( & self ) -> io:: Result < FileDesc > {
70- self . duplicate_path ( & [ ] )
71- }
72- pub fn duplicate_path ( & self , _path : & [ u8 ] ) -> io:: Result < FileDesc > {
73- unsupported ( )
74- }
75-
76- pub fn nonblocking ( & self ) -> io:: Result < bool > {
77- Ok ( false )
78- }
79-
80- pub fn set_cloexec ( & self ) -> io:: Result < ( ) > {
81- unsupported ( )
82- }
83-
84- pub fn set_nonblocking ( & self , _nonblocking : bool ) -> io:: Result < ( ) > {
85- unsupported ( )
86- }
87-
8864 pub fn fstat ( & self , stat : * mut hermit_abi:: stat ) -> io:: Result < ( ) > {
8965 cvt ( unsafe { hermit_abi:: fstat ( self . fd . as_raw_fd ( ) , stat) } ) ?;
9066 Ok ( ( ) )
9167 }
9268}
9369
94- impl < ' a > Read for & ' a FileDesc {
95- fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
96- ( * * self ) . read ( buf)
97- }
98- }
99-
10070impl IntoInner < OwnedFd > for FileDesc {
10171 fn into_inner ( self ) -> OwnedFd {
10272 self . fd
0 commit comments