pub struct SandboxConfigBuilder { /* private fields */ }Expand description
Builder for SandboxConfig.
Implementations§
Source§impl SandboxConfigBuilder
impl SandboxConfigBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with default values.
Example:
use procjail::SandboxConfigBuilder;
let config = SandboxConfigBuilder::new().build();
assert_eq!(config.timeout_seconds, 60);Sourcepub fn runtime_args(self, args: &[&str]) -> Self
pub fn runtime_args(self, args: &[&str]) -> Self
Add arguments to pass to the runtime before the harness script.
Sourcepub fn max_memory_mb(self, mb: u64) -> Self
pub fn max_memory_mb(self, mb: u64) -> Self
Set maximum memory in megabytes.
Sourcepub fn max_memory_bytes(self, bytes: u64) -> Self
pub fn max_memory_bytes(self, bytes: u64) -> Self
Set maximum memory in bytes.
Sourcepub fn max_cpu_seconds(self, seconds: u64) -> Self
pub fn max_cpu_seconds(self, seconds: u64) -> Self
Set maximum CPU time in seconds.
Sourcepub fn max_disk_mb(self, mb: u64) -> Self
pub fn max_disk_mb(self, mb: u64) -> Self
Set maximum writable disk space in megabytes.
Sourcepub fn max_processes(self, n: u64) -> Self
pub fn max_processes(self, n: u64) -> Self
Set maximum child processes/threads.
Sourcepub fn allow_localhost(self, allow: bool) -> Self
pub fn allow_localhost(self, allow: bool) -> Self
Allow localhost networking.
Sourcepub fn env_passthrough(self, vars: &[&str]) -> Self
pub fn env_passthrough(self, vars: &[&str]) -> Self
Set environment variables to pass through.
Sourcepub fn env_strip_secrets(self, strip: bool) -> Self
pub fn env_strip_secrets(self, strip: bool) -> Self
Whether to strip known secret env vars.
Sourcepub fn env_mode(self, mode: EnvMode) -> Self
pub fn env_mode(self, mode: EnvMode) -> Self
Configure how environment variables are propagated.
Sourcepub fn readonly_mount(self, host: &str, container: &str) -> Self
pub fn readonly_mount(self, host: &str, container: &str) -> Self
Add a read-only bind mount.
Sourcepub fn writable_mount(self, host: &str, container: &str) -> Self
pub fn writable_mount(self, host: &str, container: &str) -> Self
Add a read-write bind mount.
Sourcepub fn timeout_seconds(self, seconds: u64) -> Self
pub fn timeout_seconds(self, seconds: u64) -> Self
Set process timeout in seconds (0 = no timeout).
Sourcepub fn capture_stderr(self, capture: bool) -> Self
pub fn capture_stderr(self, capture: bool) -> Self
Capture stderr separately instead of piping to parent.
Sourcepub fn build(self) -> SandboxConfig
pub fn build(self) -> SandboxConfig
Build the config.
Example:
use procjail::SandboxConfig;
let config = SandboxConfig::builder().runtime("node").build();
assert_eq!(config.runtime_path.to_string_lossy(), "node");Trait Implementations§
Source§impl Clone for SandboxConfigBuilder
impl Clone for SandboxConfigBuilder
Source§fn clone(&self) -> SandboxConfigBuilder
fn clone(&self) -> SandboxConfigBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SandboxConfigBuilder
impl Debug for SandboxConfigBuilder
Auto Trait Implementations§
impl Freeze for SandboxConfigBuilder
impl RefUnwindSafe for SandboxConfigBuilder
impl Send for SandboxConfigBuilder
impl Sync for SandboxConfigBuilder
impl Unpin for SandboxConfigBuilder
impl UnsafeUnpin for SandboxConfigBuilder
impl UnwindSafe for SandboxConfigBuilder
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