From 6d8b03d2a53724c9a5bf1ba3362b73490e7834f6 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Wed, 8 Mar 2023 12:26:42 +0100 Subject: [PATCH] refactor(wasi): Move capabilities into root submodule Just a small restructuring that moves the capabilities submodule from state into the root lib. Done because it is now exported in full rather than just partially from state::, and because it is a more generic module that will probably be moved out to a separate crate soon. --- lib/wasi/src/{state => }/capabilities.rs | 0 lib/wasi/src/http/client_impl.rs | 2 +- lib/wasi/src/lib.rs | 4 +++- lib/wasi/src/os/console/mod.rs | 2 +- lib/wasi/src/runners/wcgi/handler.rs | 2 +- lib/wasi/src/state/builder.rs | 2 +- lib/wasi/src/state/env.rs | 3 ++- lib/wasi/src/state/mod.rs | 2 -- 8 files changed, 9 insertions(+), 8 deletions(-) rename lib/wasi/src/{state => }/capabilities.rs (100%) diff --git a/lib/wasi/src/state/capabilities.rs b/lib/wasi/src/capabilities.rs similarity index 100% rename from lib/wasi/src/state/capabilities.rs rename to lib/wasi/src/capabilities.rs diff --git a/lib/wasi/src/http/client_impl.rs b/lib/wasi/src/http/client_impl.rs index 078cdae6acd..6457c44968c 100644 --- a/lib/wasi/src/http/client_impl.rs +++ b/lib/wasi/src/http/client_impl.rs @@ -2,7 +2,7 @@ use std::string::FromUtf8Error; use std::sync::Arc; use crate::bindings::wasix_http_client_v1 as sys; -use crate::{Capabilities, WasiRuntime}; +use crate::{capabilities::Capabilities, WasiRuntime}; use crate::{ http::{DynHttpClient, HttpClientCapabilityV1}, diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 927a0f24a6b..bb23dc35660 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -47,6 +47,8 @@ mod syscalls; mod utils; pub mod wapm; +pub mod capabilities; + /// WAI based bindings. mod bindings; @@ -106,7 +108,7 @@ pub use crate::utils::is_wasix_module; pub use crate::{ state::{ - Capabilities, WasiEnv, WasiEnvBuilder, WasiEnvInit, WasiFunctionEnv, WasiInstanceHandles, + WasiEnv, WasiEnvBuilder, WasiEnvInit, WasiFunctionEnv, WasiInstanceHandles, WasiStateCreationError, ALL_RIGHTS, }, syscalls::types, diff --git a/lib/wasi/src/os/console/mod.rs b/lib/wasi/src/os/console/mod.rs index 57fa7e7a51b..e9245adae81 100644 --- a/lib/wasi/src/os/console/mod.rs +++ b/lib/wasi/src/os/console/mod.rs @@ -28,7 +28,7 @@ use super::{cconst::ConsoleConst, common::*, task::TaskJoinHandle}; use crate::{ bin_factory::{spawn_exec, BinFactory, ModuleCache}, os::task::{control_plane::WasiControlPlane, process::WasiProcess}, - state::Capabilities, + capabilities::Capabilities, VirtualBusError, VirtualTaskManagerExt, WasiEnv, WasiRuntime, }; diff --git a/lib/wasi/src/runners/wcgi/handler.rs b/lib/wasi/src/runners/wcgi/handler.rs index 06a8a5460cc..606b296ad29 100644 --- a/lib/wasi/src/runners/wcgi/handler.rs +++ b/lib/wasi/src/runners/wcgi/handler.rs @@ -22,7 +22,7 @@ use wcgi_host::CgiDialect; use crate::{ http::HttpClientCapabilityV1, runners::wcgi::{Callbacks, MappedDirectory}, - Capabilities, Pipe, PluggableRuntimeImplementation, VirtualTaskManager, WasiEnv, + capabilities::Capabilities, Pipe, PluggableRuntimeImplementation, VirtualTaskManager, WasiEnv, }; /// The shared object that manages the instantiaion of WASI executables and diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index 2a05886557a..8e4007a0055 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -17,7 +17,7 @@ use crate::{ os::task::control_plane::{ControlPlaneConfig, ControlPlaneError, WasiControlPlane}, state::WasiState, syscalls::types::{__WASI_STDERR_FILENO, __WASI_STDIN_FILENO, __WASI_STDOUT_FILENO}, - Capabilities, PluggableRuntimeImplementation, WasiEnv, WasiFunctionEnv, WasiRuntime, + capabilities::Capabilities, PluggableRuntimeImplementation, WasiEnv, WasiFunctionEnv, WasiRuntime, WasiRuntimeError, }; diff --git a/lib/wasi/src/state/env.rs b/lib/wasi/src/state/env.rs index d39873f4775..8f39715f2cc 100644 --- a/lib/wasi/src/state/env.rs +++ b/lib/wasi/src/state/env.rs @@ -33,9 +33,10 @@ use crate::{ SpawnedMemory, VirtualTaskManager, WasiControlPlane, WasiEnvBuilder, WasiError, WasiFunctionEnv, WasiRuntime, WasiRuntimeError, WasiStateCreationError, WasiVFork, DEFAULT_STACK_SIZE, + capabilities::Capabilities, }; -use super::{Capabilities, WasiState}; +use super::WasiState; /// Various [`TypedFunction`] and [`Global`] handles for an active WASI(X) instance. /// diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index 0fca7b274ea..ef3316eb839 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -16,7 +16,6 @@ #![allow(clippy::cognitive_complexity, clippy::too_many_arguments)] mod builder; -mod capabilities; mod env; mod func_env; mod types; @@ -39,7 +38,6 @@ use wasmer_wasi_types::wasi::{Errno, Fd as WasiFd, Rights, Snapshot0Clockid}; pub use self::{ builder::*, - capabilities::Capabilities, env::{WasiEnv, WasiEnvInit, WasiInstanceHandles}, func_env::WasiFunctionEnv, types::*,