Skip to main content

Resource

Struct Resource 

Source
pub struct Resource { /* private fields */ }
Expand description

A kind of resource.

Be careful: The documentation of Resource constants are based on a few systems. It may be inconsistent with other platforms.

§References

Linux: https://man7.org/linux/man-pages/man2/getrlimit.2.html

FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=getrlimit

NetBSD: https://man.netbsd.org/getrlimit.2

Implementations§

Source§

impl Resource

Source

pub fn set(self, soft: u64, hard: u64) -> Result<()>

Set resource limits.

§Errors

See setrlimit

Source

pub fn get(self) -> Result<(u64, u64)>

Get resource limits.

§Errors

See getrlimit

Source

pub fn as_name(self) -> &'static str

Returns the name of the resource.

§Example
assert_eq!(Resource::NOFILE.as_name(), "RLIMIT_NOFILE");
Source

pub const fn available_names() -> &'static [&'static str]

Returns available resource names.

Source

pub const fn available_resources() -> &'static [Self]

Returns available resources.

Source

pub const fn as_raw(self) -> RawResource

Returns the raw resource type.

Be careful: The actual type of RawResource can be different on different platforms.

Source§

impl Resource

Source

pub const AS: Self

The maximum size (in bytes) of the process’s virtual memory (address space).

Source

pub const CORE: Self

The maximum size (in bytes) of a core file that the process may dump.

Source

pub const CPU: Self

A limit (in seconds) on the amount of CPU time that the process can consume.

Source

pub const DATA: Self

The maximum size (in bytes) of the process’s data segment (initialized data, uninitialized data, and heap).

Source

pub const FSIZE: Self

The maximum size (in bytes) of files that the process may create.

Source

pub const LOCKS: Self

(early Linux 2.4 only)

A limit on the combined number of flock(2) locks and fcntl(2) leases that this process may establish.

Source

pub const MEMLOCK: Self

The maximum number (in bytes) of memory that may be locked into RAM.

Source

pub const MSGQUEUE: Self

A limit on the number of bytes that can be allocated for POSIX message queues for the real user ID of the calling process.

Source

pub const NICE: Self

This specifies a ceiling to which the process’s nice value can be raised using setpriority(2) or nice(2).

Source

pub const NOFILE: Self

This specifies a value one greater than the maximum file descriptor number that can be opened by this process.

Source

pub const NPROC: Self

A limit on the number of extant process (or, more precisely on Linux, threads) for the real user ID of the calling process.

Source

pub const RSS: Self

A limit (in bytes) on the process’s resident set (the number of virtual pages resident in RAM).

Source

pub const RTPRIO: Self

This specifies a ceiling on the real-time priority that may be set for this process using sched_setscheduler(2) and sched_setparam(2).

Source

pub const RTTIME: Self

A limit (in microseconds) on the amount of CPU time that a process scheduled under a real-time scheduling policy may consume without making a blocking system call.

Source

pub const SIGPENDING: Self

A limit on the number of signals that may be queued for the real user ID of the calling process.

Source

pub const STACK: Self

The maximum size (in bytes) of the process stack.

Trait Implementations§

Source§

impl Clone for Resource

Source§

fn clone(&self) -> Resource

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Resource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Resource

Source§

type Err = ParseResourceError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Resource

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Resource

Source§

fn eq(&self, other: &Resource) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Resource

Source§

impl Eq for Resource

Source§

impl StructuralPartialEq for Resource

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.