pub struct ResourceLimits {
pub memory_bytes: Option<u64>,
pub memory_high: Option<u64>,
pub memory_swap_max: Option<u64>,
pub cpu_quota_us: Option<u64>,
pub cpu_period_us: u64,
pub cpu_weight: Option<u64>,
pub pids_max: Option<u64>,
pub io_limits: Vec<IoDeviceLimit>,
}Expand description
Resource limits configuration
Fields§
§memory_bytes: Option<u64>Memory limit in bytes (None = unlimited)
memory_high: Option<u64>Memory soft limit in bytes (auto-set to 90% of memory_bytes)
memory_swap_max: Option<u64>Swap limit in bytes (Some(0) = disable swap)
cpu_quota_us: Option<u64>CPU quota in microseconds per period
cpu_period_us: u64CPU period in microseconds (default: 100000 = 100ms)
cpu_weight: Option<u64>CPU scheduling weight (1-10000)
pids_max: Option<u64>Maximum number of PIDs (None = unlimited)
io_limits: Vec<IoDeviceLimit>Per-device I/O limits
Implementations§
Source§impl ResourceLimits
impl ResourceLimits
Sourcepub fn parse_memory(s: &str) -> Result<u64>
pub fn parse_memory(s: &str) -> Result<u64>
Parse memory limit from string (e.g., “512M”, “1G”)
Sourcepub fn with_memory(self, limit: &str) -> Result<Self>
pub fn with_memory(self, limit: &str) -> Result<Self>
Set memory limit from string (e.g., “512M”, “1G”)
Automatically sets memory_high to 90% of the hard limit and disables swap (memory_swap_max = 0) unless swap was explicitly enabled.
Sourcepub fn with_swap_enabled(self) -> Self
pub fn with_swap_enabled(self) -> Self
Enable swap (removes the default swap=0 restriction)
Sourcepub fn with_cpu_cores(self, cores: f64) -> Result<Self>
pub fn with_cpu_cores(self, cores: f64) -> Result<Self>
Set CPU limit in cores (e.g., 2.5 cores)
Sourcepub fn with_cpu_weight(self, weight: u64) -> Result<Self>
pub fn with_cpu_weight(self, weight: u64) -> Result<Self>
Set CPU scheduling weight (1-10000)
Sourcepub fn with_io_limit(self, limit: IoDeviceLimit) -> Self
pub fn with_io_limit(self, limit: IoDeviceLimit) -> Self
Add an I/O device 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 · 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
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