Skip to main content

SandboxConfigBuilder

Struct SandboxConfigBuilder 

Source
pub struct SandboxConfigBuilder { /* private fields */ }
Expand description

Builder for SandboxConfig.

Implementations§

Source§

impl SandboxConfigBuilder

Source

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);
Source

pub fn runtime(self, path: &str) -> Self

Set the runtime binary path.

Source

pub fn runtime_args(self, args: &[&str]) -> Self

Add arguments to pass to the runtime before the harness script.

Source

pub fn max_memory_mb(self, mb: u64) -> Self

Set maximum memory in megabytes.

Source

pub fn max_memory_bytes(self, bytes: u64) -> Self

Set maximum memory in bytes.

Source

pub fn max_cpu_seconds(self, seconds: u64) -> Self

Set maximum CPU time in seconds.

Source

pub fn max_fds(self, fds: u64) -> Self

Set maximum open file descriptors.

Source

pub fn max_disk_mb(self, mb: u64) -> Self

Set maximum writable disk space in megabytes.

Source

pub fn max_processes(self, n: u64) -> Self

Set maximum child processes/threads.

Source

pub fn allow_localhost(self, allow: bool) -> Self

Allow localhost networking.

Source

pub fn env_passthrough(self, vars: &[&str]) -> Self

Set environment variables to pass through.

Source

pub fn env_set(self, key: &str, value: &str) -> Self

Set additional env vars in the sandbox.

Source

pub fn env_strip_secrets(self, strip: bool) -> Self

Whether to strip known secret env vars.

Source

pub fn env_strip(self, vars: &[&str]) -> Self

Add specific env vars to strip.

Source

pub fn env_mode(self, mode: EnvMode) -> Self

Configure how environment variables are propagated.

Source

pub fn strategy(self, strategy: Strategy) -> Self

Force a specific containment strategy.

Source

pub fn readonly_mount(self, host: &str, container: &str) -> Self

Add a read-only bind mount.

Source

pub fn writable_mount(self, host: &str, container: &str) -> Self

Add a read-write bind mount.

Source

pub fn timeout_seconds(self, seconds: u64) -> Self

Set process timeout in seconds (0 = no timeout).

Source

pub fn capture_stderr(self, capture: bool) -> Self

Capture stderr separately instead of piping to parent.

Source

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

Source§

fn clone(&self) -> SandboxConfigBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SandboxConfigBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SandboxConfigBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.