pub trait SandboxRuntime: Send + Sync {
// Required methods
fn create<'life0, 'async_trait>(
&'life0 self,
config: SandboxConfig,
) -> Pin<Box<dyn Future<Output = Layer3Result<SandboxId>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn destroy<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
code: &'life2 str,
language: &'life3 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<ExecutionResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn execute_tool<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
request: ToolRequest,
) -> Pin<Box<dyn Future<Output = Layer3Result<ToolResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<SandboxStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn info<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<SandboxInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<SandboxInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn reset<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
沙箱运行时 trait
提供安全隔离的代码执行环境。
Required Methods§
Sourcefn create<'life0, 'async_trait>(
&'life0 self,
config: SandboxConfig,
) -> Pin<Box<dyn Future<Output = Layer3Result<SandboxId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>(
&'life0 self,
config: SandboxConfig,
) -> Pin<Box<dyn Future<Output = Layer3Result<SandboxId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
创建沙箱
Sourcefn destroy<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn destroy<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
销毁沙箱
Sourcefn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
code: &'life2 str,
language: &'life3 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<ExecutionResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
code: &'life2 str,
language: &'life3 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<ExecutionResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
在沙箱中执行代码
Sourcefn execute_tool<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
request: ToolRequest,
) -> Pin<Box<dyn Future<Output = Layer3Result<ToolResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_tool<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
request: ToolRequest,
) -> Pin<Box<dyn Future<Output = Layer3Result<ToolResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
在沙箱中执行工具
Sourcefn status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<SandboxStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<SandboxStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取沙箱状态
Sourcefn info<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<SandboxInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn info<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SandboxId,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<SandboxInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取沙箱信息
Sourcefn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<SandboxInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<SandboxInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
列出所有活跃沙箱
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".