Skip to main content

SandboxConfig

Struct SandboxConfig 

Source
pub struct SandboxConfig {
    pub allow_network_access: bool,
    pub writable_dirs: Option<Vec<PathBuf>>,
    pub override_home_dirs: Option<Vec<OverrideHomeDir>>,
    pub passthrough_home_dirs: Option<Vec<PathBuf>>,
}
Expand description

The main configuration struct for the sandbox.

If at least one override or passthrough home directory is specified, the sandbox will use a temporary directory for the home directory instead of the user’s actual one. The original home directory can still be accessed via absolute paths (and will be read-only by default like any other directory not explicitly specified as writable).

Fields§

§allow_network_access: bool

Whether network access is allowed for the sandbox.

§writable_dirs: Option<Vec<PathBuf>>

The directories to mounted as writable for the sandbox.

§override_home_dirs: Option<Vec<OverrideHomeDir>>

Directories to recursively copy into the sandbox under a temporary directory rather than mapping the real ones.

Overriden home directories are mounted as writable for the sandbox.

§passthrough_home_dirs: Option<Vec<PathBuf>>

Directories to directly mount from the user’s home directory under the override home directory.

Passthrough directories are mounted as writable for the sandbox.

Implementations§

Source§

impl SandboxConfig

Source

pub const fn new() -> Self

Creates a new configuration with no network access, no writable directories, and no fake home directory

Source

pub const fn with_network_access(&mut self) -> &mut Self

Enables network access for the sandbox.

Source

pub fn with_writable_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self

Marks a directory as writable for the sandbox.

Source

pub fn with_override_home_dir( &mut self, override_home_dir: OverrideHomeDir, ) -> &mut Self

Marks a subdirectory of the user’s home as an override.

Source

pub fn with_passthrough_home_dir( &mut self, segments: impl IntoIterator<Item = impl AsRef<Path>>, ) -> &mut Self

Marks a subdirectory of the user’s home as passthrough.

Source

pub const fn build_sandbox(&mut self, sandbox_type: SandboxType) -> Sandbox

Builds a sandbox with the given type.

Trait Implementations§

Source§

impl Debug for SandboxConfig

Source§

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

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

impl Default for SandboxConfig

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> 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, 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.