@@ -61,23 +61,26 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
6161 if errno > u16:: MAX as i32 || errno < 0 {
6262 return Uncategorized ;
6363 }
64- match errno as u16 {
65- wasi:: ERRNO_CONNREFUSED => ConnectionRefused ,
66- wasi:: ERRNO_CONNRESET => ConnectionReset ,
67- wasi:: ERRNO_PERM | wasi:: ERRNO_ACCES => PermissionDenied ,
68- wasi:: ERRNO_PIPE => BrokenPipe ,
69- wasi:: ERRNO_NOTCONN => NotConnected ,
70- wasi:: ERRNO_CONNABORTED => ConnectionAborted ,
71- wasi:: ERRNO_ADDRNOTAVAIL => AddrNotAvailable ,
72- wasi:: ERRNO_ADDRINUSE => AddrInUse ,
73- wasi:: ERRNO_NOENT => NotFound ,
74- wasi:: ERRNO_INTR => Interrupted ,
75- wasi:: ERRNO_INVAL => InvalidInput ,
76- wasi:: ERRNO_TIMEDOUT => TimedOut ,
77- wasi:: ERRNO_EXIST => AlreadyExists ,
78- wasi:: ERRNO_AGAIN => WouldBlock ,
79- wasi:: ERRNO_NOSYS => Unsupported ,
80- wasi:: ERRNO_NOMEM => OutOfMemory ,
64+
65+ match errno {
66+ e if e == wasi:: ERRNO_CONNREFUSED . raw ( ) . into ( ) => ConnectionRefused ,
67+ e if e == wasi:: ERRNO_CONNRESET . raw ( ) . into ( ) => ConnectionReset ,
68+ e if e == wasi:: ERRNO_PERM . raw ( ) . into ( ) || e == wasi:: ERRNO_ACCES . raw ( ) . into ( ) => {
69+ PermissionDenied
70+ }
71+ e if e == wasi:: ERRNO_PIPE . raw ( ) . into ( ) => BrokenPipe ,
72+ e if e == wasi:: ERRNO_NOTCONN . raw ( ) . into ( ) => NotConnected ,
73+ e if e == wasi:: ERRNO_CONNABORTED . raw ( ) . into ( ) => ConnectionAborted ,
74+ e if e == wasi:: ERRNO_ADDRNOTAVAIL . raw ( ) . into ( ) => AddrNotAvailable ,
75+ e if e == wasi:: ERRNO_ADDRINUSE . raw ( ) . into ( ) => AddrInUse ,
76+ e if e == wasi:: ERRNO_NOENT . raw ( ) . into ( ) => NotFound ,
77+ e if e == wasi:: ERRNO_INTR . raw ( ) . into ( ) => Interrupted ,
78+ e if e == wasi:: ERRNO_INVAL . raw ( ) . into ( ) => InvalidInput ,
79+ e if e == wasi:: ERRNO_TIMEDOUT . raw ( ) . into ( ) => TimedOut ,
80+ e if e == wasi:: ERRNO_EXIST . raw ( ) . into ( ) => AlreadyExists ,
81+ e if e == wasi:: ERRNO_AGAIN . raw ( ) . into ( ) => WouldBlock ,
82+ e if e == wasi:: ERRNO_NOSYS . raw ( ) . into ( ) => Unsupported ,
83+ e if e == wasi:: ERRNO_NOMEM . raw ( ) . into ( ) => OutOfMemory ,
8184 _ => Uncategorized ,
8285 }
8386}
@@ -96,6 +99,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
9699 return ret;
97100}
98101
99- fn err2io ( err : wasi:: Error ) -> std_io:: Error {
100- std_io:: Error :: from_raw_os_error ( err. raw_error ( ) . into ( ) )
102+ fn err2io ( err : wasi:: Errno ) -> std_io:: Error {
103+ std_io:: Error :: from_raw_os_error ( err. raw ( ) . into ( ) )
101104}
0 commit comments