Struct lunatic::ProcessConfig

source ·
pub struct ProcessConfig(_);
Expand description

Process configurations determine permissions of processes.

The functions spawn_config & spawn_link_config can be used to create processes with a specific configuration.

Implementations§

source§

impl ProcessConfig

source

pub fn new() -> Result<Self, LunaticError>

Create a new process configuration with all permissions denied.

There is no memory or fuel limit set on the newly created configuration, they are not inherited from parent.

source

pub fn id(&self) -> i64

Returns the id of the configuration resource or -1 in case it’s an inherited configuration.

source

pub fn set_max_memory(&mut self, max_memory: u64)

Sets the maximum amount of memory in bytes that can be used by a process.

If a process tries to allocate more memory with memory.grow, the instruction is going to return -1.

source

pub fn get_max_memory(&self) -> u64

Returns the maximum amount of memory in bytes.

source

pub fn set_max_fuel(&mut self, max_fuel: u64)

Sets the maximum amount of fuel available to the process.

One unit of fuel is approximately 100k wasm instructions. If a process runs out of fuel it will trap.

source

pub fn get_max_fuel(&self) -> u64

Returns the maximum amount of fuel.

source

pub fn set_can_compile_modules(&mut self, can: bool)

Sets the ability of a process to compile WebAssembly modules.

source

pub fn can_compile_modules(&self) -> bool

Returns true if processes can compile WebAssembly modules.

source

pub fn set_can_create_configs(&mut self, can: bool)

Sets the ability of a process to create their own sub-configuration.

This setting can be dangerous. If a process is missing a permission, but has the possibility to create new configurations, it can spawn sub-processes using a new config that has the permission enabled.

source

pub fn can_create_configs(&self) -> bool

Returns true if processes can create their own configurations.

source

pub fn set_can_spawn_processes(&mut self, can: bool)

Sets the ability of a process to spawn sub-processes.

source

pub fn can_spawn_processes(&self) -> bool

Returns true if processes can spawn sub-processes.

source

pub fn add_environment_variable(&mut self, key: &str, value: &str)

Adds environment variable.

source

pub fn add_command_line_argument(&mut self, argument: &str)

Adds command line argument.

Trait Implementations§

source§

impl Debug for ProcessConfig

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.