pub struct ResourceLimits {
pub max_memory_mb: u64,
pub max_pids: u32,
pub max_disk_mb: u64,
pub cpu_time_secs: u64,
pub timeout_secs: u64,
}Expand description
Resource limits for sandboxed execution.
Following the field guide’s recommendation for resource accounting: “CPU, memory, disk, timeouts, and PIDs.”
Fields§
§max_memory_mb: u64Maximum memory usage in megabytes (0 = unlimited).
max_pids: u32Maximum number of processes/threads (0 = unlimited). Prevents fork bombs.
max_disk_mb: u64Maximum disk write in megabytes (0 = unlimited).
cpu_time_secs: u64CPU time limit in seconds (0 = unlimited).
timeout_secs: u64Wall clock timeout in seconds (0 = use default).
Implementations§
Source§impl ResourceLimits
impl ResourceLimits
Sourcepub fn conservative() -> Self
pub fn conservative() -> Self
Create conservative limits suitable for untrusted code. Following field guide: “Resource limits: CPU, memory, disk, timeouts, and PIDs.”
Sourcepub fn with_disk_mb(self, mb: u64) -> Self
pub fn with_disk_mb(self, mb: u64) -> Self
Builder: set disk limit.
Sourcepub fn with_cpu_time_secs(self, secs: u64) -> Self
pub fn with_cpu_time_secs(self, secs: u64) -> Self
Builder: set CPU time limit.
Trait Implementations§
Source§impl Clone for ResourceLimits
impl Clone for ResourceLimits
Source§fn clone(&self) -> ResourceLimits
fn clone(&self) -> ResourceLimits
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResourceLimits
impl Debug for ResourceLimits
Source§impl Default for ResourceLimits
impl Default for ResourceLimits
Source§impl<'de> Deserialize<'de> for ResourceLimits
impl<'de> Deserialize<'de> for ResourceLimits
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ResourceLimits
Source§impl PartialEq for ResourceLimits
impl PartialEq for ResourceLimits
Source§impl Serialize for ResourceLimits
impl Serialize for ResourceLimits
impl StructuralPartialEq for ResourceLimits
Auto Trait Implementations§
impl Freeze for ResourceLimits
impl RefUnwindSafe for ResourceLimits
impl Send for ResourceLimits
impl Sync for ResourceLimits
impl Unpin for ResourceLimits
impl UnsafeUnpin for ResourceLimits
impl UnwindSafe for ResourceLimits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.