Skip to main content

Sandbox

Trait Sandbox 

Source
pub trait Sandbox: Send + Sync {
    // Required methods
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        code: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<ExecutionResult, SandboxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn is_ready<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, SandboxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stop<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), SandboxError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for sandbox implementations.

A sandbox provides isolated code execution with resource limits.

Required Methods§

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, code: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<ExecutionResult, SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute code in the sandbox.

§Arguments
  • code - The code/command to execute
§Errors

Returns an error if execution fails.

Source

fn is_ready<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the sandbox is ready.

§Errors

Returns an error if the sandbox is not accessible.

Source

fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop and cleanup the sandbox.

§Errors

Returns an error if cleanup fails.

Trait Implementations§

Source§

impl Sandbox for Box<dyn Sandbox>

Implementation of Sandbox for Box<dyn Sandbox>. This allows using trait objects with generic sandbox validators.

Source§

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, code: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<ExecutionResult, SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute code in the sandbox. Read more
Source§

fn is_ready<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the sandbox is ready. Read more
Source§

fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop and cleanup the sandbox. Read more

Implementations on Foreign Types§

Source§

impl Sandbox for Box<dyn Sandbox>

Implementation of Sandbox for Box<dyn Sandbox>. This allows using trait objects with generic sandbox validators.

Source§

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, code: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<ExecutionResult, SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn is_ready<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), SandboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§