pub struct SandboxManager { /* private fields */ }Expand description
Manages Docker-based code execution sandboxes.
Each sandbox is a Docker container running the in-sandbox FastAPI/Jupyter server. The manager handles container lifecycle and proxies execution requests to the appropriate container.
Implementations§
Source§impl SandboxManager
impl SandboxManager
Sourcepub fn new() -> SandboxManager
pub fn new() -> SandboxManager
Create a new SandboxManager and spawn the background idle-cleanup task.
Sourcepub async fn list_sandboxes(&self) -> Vec<SandboxInfo>
pub async fn list_sandboxes(&self) -> Vec<SandboxInfo>
List all tracked sandbox containers.
Sourcepub async fn get_sandbox(&self, id: &str) -> Option<SandboxInfo>
pub async fn get_sandbox(&self, id: &str) -> Option<SandboxInfo>
Get a sandbox by container ID (or unique prefix).
Sourcepub async fn create_sandbox(
&self,
req: ResolvedCreateSandboxRequest,
) -> Result<SandboxInfo, String>
pub async fn create_sandbox( &self, req: ResolvedCreateSandboxRequest, ) -> Result<SandboxInfo, String>
Create a new sandbox container and return its info.
Sourcepub async fn execute_in_sandbox(
&self,
id: &str,
req: ExecuteRequest,
) -> Result<Response, String>
pub async fn execute_in_sandbox( &self, id: &str, req: ExecuteRequest, ) -> Result<Response, String>
Execute code inside a sandbox and return a streaming reqwest response.
The response body is an NDJSON stream of SandboxOutputEvent objects
as produced by the in-sandbox FastAPI server.
Sourcepub async fn delete_sandbox(&self, id: &str) -> Result<(), String>
pub async fn delete_sandbox(&self, id: &str) -> Result<(), String>
Stop and remove a sandbox container.
Sourcepub async fn recreate_sandbox(
&self,
id: &str,
req: ResolvedCreateSandboxRequest,
) -> Result<SandboxInfo, String>
pub async fn recreate_sandbox( &self, id: &str, req: ResolvedCreateSandboxRequest, ) -> Result<SandboxInfo, String>
Replace an existing sandbox with a newly created sandbox using a mutated policy.
Trait Implementations§
Source§impl Default for SandboxManager
impl Default for SandboxManager
Source§fn default() -> SandboxManager
fn default() -> SandboxManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SandboxManager
impl !RefUnwindSafe for SandboxManager
impl Send for SandboxManager
impl Sync for SandboxManager
impl Unpin for SandboxManager
impl UnsafeUnpin for SandboxManager
impl !UnwindSafe for SandboxManager
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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