diff --git a/crates/wasi-preview1-component-adapter/src/descriptors.rs b/crates/wasi-preview1-component-adapter/src/descriptors.rs index da752f08cd2d..72d211cf26f8 100644 --- a/crates/wasi-preview1-component-adapter/src/descriptors.rs +++ b/crates/wasi-preview1-component-adapter/src/descriptors.rs @@ -3,7 +3,6 @@ use crate::bindings::wasi::cli::{ }; use crate::bindings::wasi::filesystem::types as filesystem; use crate::bindings::wasi::io::streams::{InputStream, OutputStream}; -use crate::bindings::wasi::sockets::tcp; use crate::{BlockingMode, BumpArena, File, ImportAlloc, TrappingUnwrap, WasmStr}; use core::cell::{Cell, OnceCell, UnsafeCell}; use core::mem::MaybeUninit; @@ -93,16 +92,12 @@ impl Streams { } } -#[allow(dead_code)] // until Socket is implemented pub enum StreamType { /// Streams for implementing stdio. Stdio(IsATTY), /// Streaming data with a file. File(File), - - /// Streaming data with a socket connection. - Socket(tcp::TcpSocket), } pub enum IsATTY { @@ -370,18 +365,6 @@ impl Descriptors { } } - #[allow(dead_code)] // until Socket is implemented - pub fn get_socket(&self, fd: Fd) -> Result<&tcp::TcpSocket, Errno> { - match self.get(fd)? { - Descriptor::Streams(Streams { - type_: StreamType::Socket(socket), - .. - }) => Ok(&*socket), - Descriptor::Closed(_) => Err(wasi::ERRNO_BADF), - _ => Err(wasi::ERRNO_INVAL), - } - } - pub fn get_file(&self, fd: Fd) -> Result<&File, Errno> { self.get_file_with_error(fd, wasi::ERRNO_INVAL) } diff --git a/crates/wasi-preview1-component-adapter/src/lib.rs b/crates/wasi-preview1-component-adapter/src/lib.rs index aa4efe2a6993..a701c1d71fcf 100644 --- a/crates/wasi-preview1-component-adapter/src/lib.rs +++ b/crates/wasi-preview1-component-adapter/src/lib.rs @@ -4,7 +4,6 @@ use crate::bindings::wasi::filesystem::types as filesystem; use crate::bindings::wasi::io::poll; use crate::bindings::wasi::io::streams; use crate::bindings::wasi::random::random; -use crate::bindings::wasi::sockets::network; use core::cell::OnceCell; use core::cell::{Cell, RefCell, RefMut, UnsafeCell}; use core::cmp::min; @@ -589,11 +588,6 @@ pub unsafe extern "C" fn fd_fdstat_get(fd: Fd, stat: *mut Fdstat) -> Errno { Ok(()) } Descriptor::Closed(_) => Err(ERRNO_BADF), - Descriptor::Streams(Streams { - input: _, - output: _, - type_: StreamType::Socket(_), - }) => unreachable!(), } }) } @@ -1645,26 +1639,6 @@ impl Drop for Pollables { } } -impl From for Errno { - fn from(error: network::ErrorCode) -> Errno { - match error { - network::ErrorCode::Unknown => unreachable!(), // TODO - /* TODO - // Use a black box to prevent the optimizer from generating a - // lookup table, which would require a static initializer. - ConnectionAborted => black_box(ERRNO_CONNABORTED), - ConnectionRefused => ERRNO_CONNREFUSED, - ConnectionReset => ERRNO_CONNRESET, - HostUnreachable => ERRNO_HOSTUNREACH, - NetworkDown => ERRNO_NETDOWN, - NetworkUnreachable => ERRNO_NETUNREACH, - Timedout => ERRNO_TIMEDOUT, - */ - _ => unreachable!(), - } - } -} - /// Concurrently poll for the occurrence of a set of events. #[no_mangle] pub unsafe extern "C" fn poll_oneoff( @@ -1852,25 +1826,6 @@ pub unsafe extern "C" fn poll_oneoff( } Err(e) => (e.into(), 1, 0), }, - StreamType::Socket(_connection) => { - unreachable!() // TODO - /* - match tcp::bytes_readable(*connection) { - Ok(result) => ( - ERRNO_SUCCESS, - result.0, - if result.1 { - EVENTRWFLAGS_FD_READWRITE_HANGUP - } else { - 0 - } - ) - Err(e) => { - (e.into(), 1, 0) - } - } - */ - } StreamType::Stdio(_) => (ERRNO_SUCCESS, 1, 0), }, _ => unreachable!(), @@ -1885,25 +1840,6 @@ pub unsafe extern "C" fn poll_oneoff( match desc { Descriptor::Streams(streams) => match &streams.type_ { StreamType::File(_) | StreamType::Stdio(_) => (ERRNO_SUCCESS, 1, 0), - StreamType::Socket(_connection) => { - unreachable!() // TODO - /* - match tcp::bytes_writable(connection) { - Ok(result) => ( - ERRNO_SUCCESS, - result.0, - if result.1 { - EVENTRWFLAGS_FD_READWRITE_HANGUP - } else { - 0 - } - ) - Err(e) => { - (e.into(), 0, 0) - } - } - */ - } }, _ => unreachable!(), }