pub struct Limits {
pub timeout: Option<Duration>,
pub memory_bytes: Option<usize>,
pub max_instructions: Option<u64>,
pub max_stack_depth: Option<usize>,
pub max_output_bytes: Option<usize>,
pub max_fs_ops: Option<usize>,
pub max_net_ops: Option<usize>,
pub max_concurrent_tasks: Option<usize>,
}Expand description
Resource limits for script execution.
These limits control how much resources a script can consume.
All limits are optional - None means unlimited.
Fields§
§timeout: Option<Duration>Maximum execution time.
memory_bytes: Option<usize>Maximum memory usage in bytes.
max_instructions: Option<u64>Maximum number of VM instructions.
max_stack_depth: Option<usize>Maximum call stack depth.
max_output_bytes: Option<usize>Maximum output size in bytes.
max_fs_ops: Option<usize>Maximum filesystem operations.
max_net_ops: Option<usize>Maximum network operations.
max_concurrent_tasks: Option<usize>Maximum concurrent tasks/coroutines.
Implementations§
Source§impl Limits
impl Limits
Sourcepub fn with_timeout(self, timeout: Duration) -> Limits
pub fn with_timeout(self, timeout: Duration) -> Limits
Set the timeout.
Sourcepub fn with_memory_bytes(self, bytes: usize) -> Limits
pub fn with_memory_bytes(self, bytes: usize) -> Limits
Set the memory limit in bytes.
Sourcepub fn with_memory_mb(self, mb: usize) -> Limits
pub fn with_memory_mb(self, mb: usize) -> Limits
Set the memory limit in megabytes.
Sourcepub fn with_max_instructions(self, count: u64) -> Limits
pub fn with_max_instructions(self, count: u64) -> Limits
Set the instruction limit.
Sourcepub fn with_max_stack_depth(self, depth: usize) -> Limits
pub fn with_max_stack_depth(self, depth: usize) -> Limits
Set the stack depth limit.
Sourcepub fn with_max_output_bytes(self, bytes: usize) -> Limits
pub fn with_max_output_bytes(self, bytes: usize) -> Limits
Set the output size limit in bytes.
Sourcepub fn with_max_fs_ops(self, ops: usize) -> Limits
pub fn with_max_fs_ops(self, ops: usize) -> Limits
Set the filesystem operations limit.
Sourcepub fn with_max_net_ops(self, ops: usize) -> Limits
pub fn with_max_net_ops(self, ops: usize) -> Limits
Set the network operations limit.
Sourcepub fn with_max_concurrent_tasks(self, tasks: usize) -> Limits
pub fn with_max_concurrent_tasks(self, tasks: usize) -> Limits
Set the concurrent tasks limit.
Sourcepub fn no_timeout(self) -> Limits
pub fn no_timeout(self) -> Limits
Remove the timeout limit.
Sourcepub fn check_time(&self, elapsed: Duration) -> Result<(), LimitViolation>
pub fn check_time(&self, elapsed: Duration) -> Result<(), LimitViolation>
Check if time limit is exceeded.
Sourcepub fn check_memory(&self, used: usize) -> Result<(), LimitViolation>
pub fn check_memory(&self, used: usize) -> Result<(), LimitViolation>
Check if memory limit is exceeded.
Sourcepub fn check_instructions(&self, count: u64) -> Result<(), LimitViolation>
pub fn check_instructions(&self, count: u64) -> Result<(), LimitViolation>
Check if instruction limit is exceeded.
Sourcepub fn check_stack_depth(&self, depth: usize) -> Result<(), LimitViolation>
pub fn check_stack_depth(&self, depth: usize) -> Result<(), LimitViolation>
Check if stack depth limit is exceeded.