pub struct WasiSandbox { /* private fields */ }Expand description
A Profile-B WASI sandbox: a wasm32-wasip1 guest whose filesystem is a
Subject-scoped VFS [Mount].
Implementations§
Source§impl WasiSandbox
impl WasiSandbox
Sourcepub fn wasi_for(
wasm: &[u8],
subject: Subject,
mount: Arc<dyn Mount>,
) -> Result<Self>
pub fn wasi_for( wasm: &[u8], subject: Subject, mount: Arc<dyn Mount>, ) -> Result<Self>
Build a Profile-B sandbox over wasm (a wasm32-wasip1 module), bound to
subject, whose ONLY filesystem is mount (preopened at guest path /).
No host preopen, no sockets, clocks+random withheld/VFS-mediated. The
returned sandbox MUST be driven from a plain (non-async) thread — the Mount
adapters block_on an inner runtime, which would panic on a tokio worker.
Sourcepub fn engine(&self) -> &Engine
pub fn engine(&self) -> &Engine
The engine (spawn a crate::EpochTimer on it for the wall-clock bound).
Sourcepub fn run_start(&self, fuel: u64) -> Result<()>
pub fn run_start(&self, fuel: u64) -> Result<()>
Run the guest’s _start (a wasip1 command) under a fuel budget.
Returns Ok(()) on clean exit (or I32Exit(0)); a nonzero proc_exit
surfaces as an error carrying the exit code. The guest’s filesystem side
effects land in the VFS Mount.
Sourcepub fn run_start_with_epoch_deadline(&self, ticks: u64) -> Result<()>
pub fn run_start_with_epoch_deadline(&self, ticks: u64) -> Result<()>
Run _start under a WALL-CLOCK epoch deadline of ticks (paired with an
crate::EpochTimer on Self::engine). Fuel is set effectively infinite
so the epoch is the limiter — the production DoS bound for Profile B.
Auto Trait Implementations§
impl Freeze for WasiSandbox
impl !RefUnwindSafe for WasiSandbox
impl Send for WasiSandbox
impl Sync for WasiSandbox
impl Unpin for WasiSandbox
impl UnsafeUnpin for WasiSandbox
impl !UnwindSafe for WasiSandbox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more