pub struct Sandbox { /* private fields */ }Expand description
A sandboxed execution environment
Implementations§
Source§impl Sandbox
impl Sandbox
Sourcepub fn new(config: SandboxConfig) -> Self
pub fn new(config: SandboxConfig) -> Self
Create a new sandbox with the given configuration
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a sandbox with default configuration
Source§impl Sandbox
impl Sandbox
Sourcepub async fn init(&mut self) -> Result<(), SandboxError>
pub async fn init(&mut self) -> Result<(), SandboxError>
Initialize the sandbox — create the workdir if configured
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the sandbox is initialized
Sourcepub fn config(&self) -> &SandboxConfig
pub fn config(&self) -> &SandboxConfig
Get the sandbox configuration
Sourcepub fn resolve_path(&self, path: &str) -> Result<PathBuf, SandboxError>
pub fn resolve_path(&self, path: &str) -> Result<PathBuf, SandboxError>
Resolve a path within the sandbox
Returns an error if the resolved path is outside the sandbox workdir.
Sourcepub fn check_read_path(&self, path: &str) -> Result<PathBuf, SandboxError>
pub fn check_read_path(&self, path: &str) -> Result<PathBuf, SandboxError>
Check if a path is allowed for reading
Sourcepub fn check_write_path(&self, path: &str) -> Result<PathBuf, SandboxError>
pub fn check_write_path(&self, path: &str) -> Result<PathBuf, SandboxError>
Check if a path is allowed for writing
Sourcepub fn check_network(&self) -> Result<(), SandboxError>
pub fn check_network(&self) -> Result<(), SandboxError>
Check if network access is allowed
Sourcepub fn filtered_env(&self) -> Vec<(String, String)>
pub fn filtered_env(&self) -> Vec<(String, String)>
Get a filtered environment for sandboxed processes
Sourcepub async fn cleanup(&mut self) -> Result<(), SandboxError>
pub async fn cleanup(&mut self) -> Result<(), SandboxError>
Clean up the sandbox workdir
Sourcepub async fn create_temp_file(
&self,
prefix: &str,
suffix: &str,
) -> Result<PathBuf, SandboxError>
pub async fn create_temp_file( &self, prefix: &str, suffix: &str, ) -> Result<PathBuf, SandboxError>
Create a temporary file within the sandbox
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sandbox
impl RefUnwindSafe for Sandbox
impl Send for Sandbox
impl Sync for Sandbox
impl Unpin for Sandbox
impl UnsafeUnpin for Sandbox
impl UnwindSafe for Sandbox
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request