pub struct Pid(/* private fields */);Available on crate feature
sys only.Expand description
Process ID.
This type provides type-safe process IDs. It uses the newtype pattern
with #[repr(transparent)] for zero-cost abstraction.
§Platform Differences
- Linux/Unix: PIDs are typically 32-bit unsigned integers
- Windows: PIDs are typically 32-bit unsigned integers
§Special Values
0: Typically refers to the kernel or scheduler (may be invalid on some systems)1: Typically the init process (or systemd on modern Linux)
Implementations§
Source§impl Pid
impl Pid
Sourcepub const MAX: u32 = 4_194_303
Available on Linux only.
pub const MAX: u32 = 4_194_303
Maximum valid PID value (platform-dependent, typically 2^31-1 or 2^32-1)
Sourcepub const fn new(value: u32) -> Result<Self, PidError>
pub const fn new(value: u32) -> Result<Self, PidError>
Creates a new PID from a value.
§Errors
Returns an error if the value is zero or exceeds the maximum.
Sourcepub const fn new_unchecked(value: u32) -> Self
pub const fn new_unchecked(value: u32) -> Self
Sourcepub const fn is_system_process(&self) -> bool
pub const fn is_system_process(&self) -> bool
Returns true if this is likely a system process.
System processes typically have low PIDs (below 100 on most systems).
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Pid
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Pid
Available on crate feature
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for Pid
impl<'de> Deserialize<'de> for Pid
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 Ord for Pid
impl Ord for Pid
Source§impl PartialOrd for Pid
impl PartialOrd for Pid
impl Copy for Pid
impl Eq for Pid
impl StructuralPartialEq for Pid
Auto Trait Implementations§
impl Freeze for Pid
impl RefUnwindSafe for Pid
impl Send for Pid
impl Sync for Pid
impl Unpin for Pid
impl UnwindSafe for Pid
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