Struct rlimit::Resource

source ·
pub struct Resource { /* private fields */ }
Expand description

A kind of resource.

All resource constants are available on all unix platforms. Passing an unsupported resource to [set|get|p]rlimit will result in a custom IO error.

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

AIX: https://www.ibm.com/docs/en/aix/7.3?topic=g-getrlimit-getrlimit64-setrlimit-setrlimit64-vlimit-subroutine

Implementations§

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 KQUEUES: Self = _

The maximum number of kqueues this user id is allowed to 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 NOVMON: Self = _

The number of open vnode monitors.

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 NPTS: Self = _

The maximum number of pseudo-terminals this user id is allowed to create.

source

pub const NTHR: Self = _

The maximum number of simultaneous threads (Lightweight Processes) for this user id. Kernel threads and the first thread of each process are not counted against this limit.

source

pub const POSIXLOCKS: Self = _

The maximum number of POSIX-type advisory-mode locks available to this user.

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 SBSIZE: Self = _

The maximum size (in bytes) of socket buffer usage for this user. This limits the amount of network memory, and hence the amount of mbufs, that this user may hold at any time.

source

pub const SIGPENDING: Self = _

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

source

pub const STACK: Self = _

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

source

pub const SWAP: Self = _

The maximum size (in bytes) of the swap space that may be reserved or used by all of this user id’s processes.

source

pub const THREADS: Self = _

AIX: The maximum number of threads each process can create. This limit is enforced by the kernel and the pthread debug library.

source

pub const UMTXP: Self = _

The number of shared locks a given user may create simultaneously.

source

pub const VMEM: Self = _

An alias for RLIMIT_AS. The maximum size of a process’s mapped address space in bytes.

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 get_soft(self) -> Result<u64>

Get soft resource limit (rlim_cur)

Errors

See getrlimit

source

pub fn get_hard(self) -> Result<u64>

Get hard resource limit (rlim_max)

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 is_supported(self) -> bool

Returns true if the current platform supports this resource.

Trait Implementations§

source§

impl Clone for Resource

source§

fn clone(&self) -> Resource

Returns a copy 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

§

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<Resource> for Resource

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 StructuralEq for Resource

source§

impl StructuralPartialEq for Resource

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.