pub struct ResourceLimits {
pub memory: Option<String>,
pub cpus: Option<String>,
pub cpu_weight: Option<String>,
}Expand description
Resource limits that map to systemd cgroup directives.
Each field is None when the limit is not set. Values are stored in the
container’s state file and converted to a systemd drop-in at start time.
Fields§
§memory: Option<String>MemoryMax=, e.g. “512M”, “2G”
cpus: Option<String>CPUQuota=, stored as a number of CPUs (e.g. “2” → 200%)
cpu_weight: Option<String>CPUWeight=, integer 1-10000
Implementations§
Source§impl ResourceLimits
impl ResourceLimits
Sourcepub fn from_state(state: &State) -> Self
pub fn from_state(state: &State) -> Self
Read limits from a state file’s key-value pairs.
Sourcepub fn write_to_state(&self, state: &mut State)
pub fn write_to_state(&self, state: &mut State)
Write limits into a state’s key-value pairs.
Set fields are written; unset fields are removed from the state.
Sourcepub fn dropin_content(&self) -> Option<String>
pub fn dropin_content(&self) -> Option<String>
Generate the content of a systemd drop-in [Service] section.
Returns None if no limits are set.
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
Source§impl Default for ResourceLimits
impl Default for ResourceLimits
Source§fn default() -> ResourceLimits
fn default() -> ResourceLimits
Returns the “default value” for a type. Read more
Source§impl PartialEq for ResourceLimits
impl PartialEq 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