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
impl ProcessConfig
sourcepub fn new() -> Result<Self, LunaticError>
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.
sourcepub fn id(&self) -> i64
pub fn id(&self) -> i64
Returns the id of the configuration resource or -1 in case it’s an inherited configuration.
sourcepub fn set_max_memory(&mut self, max_memory: u64)
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.
sourcepub fn get_max_memory(&self) -> u64
pub fn get_max_memory(&self) -> u64
Returns the maximum amount of memory in bytes.
sourcepub fn set_max_fuel(&mut self, max_fuel: u64)
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.
sourcepub fn get_max_fuel(&self) -> u64
pub fn get_max_fuel(&self) -> u64
Returns the maximum amount of fuel.
sourcepub fn set_can_compile_modules(&mut self, can: bool)
pub fn set_can_compile_modules(&mut self, can: bool)
Sets the ability of a process to compile WebAssembly modules.
sourcepub fn can_compile_modules(&self) -> bool
pub fn can_compile_modules(&self) -> bool
Returns true if processes can compile WebAssembly modules.
sourcepub fn set_can_create_configs(&mut self, can: bool)
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.
sourcepub fn can_create_configs(&self) -> bool
pub fn can_create_configs(&self) -> bool
Returns true if processes can create their own configurations.
sourcepub fn set_can_spawn_processes(&mut self, can: bool)
pub fn set_can_spawn_processes(&mut self, can: bool)
Sets the ability of a process to spawn sub-processes.
sourcepub fn can_spawn_processes(&self) -> bool
pub fn can_spawn_processes(&self) -> bool
Returns true if processes can spawn sub-processes.
sourcepub fn add_environment_variable(&mut self, key: &str, value: &str)
pub fn add_environment_variable(&mut self, key: &str, value: &str)
Adds environment variable.
sourcepub fn add_command_line_argument(&mut self, argument: &str)
pub fn add_command_line_argument(&mut self, argument: &str)
Adds command line argument.