pub struct LinuxRlimit { /* private fields */ }Expand description
Represents a resource limit for a Linux process.
This struct encapsulates a resource type and its corresponding soft and hard limits. The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit.
§Examples
use microsandbox_core::vm::{LinuxRlimit, LinuxRLimitResource};
// Create a new resource limit for CPU time
let cpu_limit = LinuxRlimit::new(LinuxRLimitResource::RLIMIT_CPU, 10, 20);
assert_eq!(cpu_limit.get_resource(), &LinuxRLimitResource::RLIMIT_CPU);
assert_eq!(cpu_limit.get_soft(), &10);
assert_eq!(cpu_limit.get_hard(), &20);
// Parse a resource limit from a string
let nofile_limit: LinuxRlimit = "RLIMIT_NOFILE=1000:2000".parse().unwrap();
assert_eq!(nofile_limit.get_resource(), &LinuxRLimitResource::RLIMIT_NOFILE);
assert_eq!(nofile_limit.get_soft(), &1000);
assert_eq!(nofile_limit.get_hard(), &2000);Implementations§
Source§impl LinuxRlimit
impl LinuxRlimit
Sourcepub fn get_resource(&self) -> &LinuxRLimitResource
pub fn get_resource(&self) -> &LinuxRLimitResource
The resource to limit.
Source§impl LinuxRlimit
impl LinuxRlimit
Sourcepub fn new(resource: LinuxRLimitResource, soft: u64, hard: u64) -> Self
pub fn new(resource: LinuxRLimitResource, soft: u64, hard: u64) -> Self
Creates a new LinuxRlimit instance with the specified resource, soft limit, and hard limit.
§Arguments
resource- The resource type to limit.soft- The soft limit value.hard- The hard limit value.
§Examples
use microsandbox_core::vm::{LinuxRlimit, LinuxRLimitResource};
let cpu_limit = LinuxRlimit::new(LinuxRLimitResource::RLIMIT_CPU, 10, 20);
assert_eq!(cpu_limit.get_resource(), &LinuxRLimitResource::RLIMIT_CPU);
assert_eq!(cpu_limit.get_soft(), &10);
assert_eq!(cpu_limit.get_hard(), &20);Trait Implementations§
Source§impl Clone for LinuxRlimit
impl Clone for LinuxRlimit
Source§fn clone(&self) -> LinuxRlimit
fn clone(&self) -> LinuxRlimit
Returns a copy 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 LinuxRlimit
impl Debug for LinuxRlimit
Source§impl<'de> Deserialize<'de> for LinuxRlimit
impl<'de> Deserialize<'de> for LinuxRlimit
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
Source§impl Display for LinuxRlimit
impl Display for LinuxRlimit
Source§impl FromStr for LinuxRlimit
impl FromStr for LinuxRlimit
Source§impl PartialEq for LinuxRlimit
impl PartialEq for LinuxRlimit
Source§impl Serialize for LinuxRlimit
impl Serialize for LinuxRlimit
impl Eq for LinuxRlimit
impl StructuralPartialEq for LinuxRlimit
Auto Trait Implementations§
impl Freeze for LinuxRlimit
impl RefUnwindSafe for LinuxRlimit
impl Send for LinuxRlimit
impl Sync for LinuxRlimit
impl Unpin for LinuxRlimit
impl UnwindSafe for LinuxRlimit
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,
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more