forked from bytecodealliance/wstd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
29 lines (25 loc) · 1.15 KB
/
mod.rs
File metadata and controls
29 lines (25 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Async network abstractions.
use std::io::{self, ErrorKind};
use wasip2::sockets::network::ErrorCode;
mod tcp_listener;
mod tcp_stream;
pub use tcp_listener::*;
pub use tcp_stream::*;
fn to_io_err(err: ErrorCode) -> io::Error {
match err {
ErrorCode::Unknown => ErrorKind::Other.into(),
ErrorCode::AccessDenied => ErrorKind::PermissionDenied.into(),
ErrorCode::NotSupported => ErrorKind::Unsupported.into(),
ErrorCode::InvalidArgument => ErrorKind::InvalidInput.into(),
ErrorCode::OutOfMemory => ErrorKind::OutOfMemory.into(),
ErrorCode::Timeout => ErrorKind::TimedOut.into(),
ErrorCode::WouldBlock => ErrorKind::WouldBlock.into(),
ErrorCode::InvalidState => ErrorKind::InvalidData.into(),
ErrorCode::AddressInUse => ErrorKind::AddrInUse.into(),
ErrorCode::ConnectionRefused => ErrorKind::ConnectionRefused.into(),
ErrorCode::ConnectionReset => ErrorKind::ConnectionReset.into(),
ErrorCode::ConnectionAborted => ErrorKind::ConnectionAborted.into(),
ErrorCode::ConcurrencyConflict => ErrorKind::AlreadyExists.into(),
_ => ErrorKind::Other.into(),
}
}