]>
git.proxmox.com Git - rustc.git/blob - vendor/sysinfo/src/apple/process.rs
1 // Take a look at the license at the top of the repository in the LICENSE file.
5 pub use crate::sys
::inner
::process
::*;
6 use crate::ProcessStatus
;
9 impl From
<u32> for ProcessStatus
{
10 fn from(status
: u32) -> ProcessStatus
{
12 1 => ProcessStatus
::Idle
,
13 2 => ProcessStatus
::Run
,
14 3 => ProcessStatus
::Sleep
,
15 4 => ProcessStatus
::Stop
,
16 5 => ProcessStatus
::Zombie
,
17 x
=> ProcessStatus
::Unknown(x
),
22 impl fmt
::Display
for ProcessStatus
{
23 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
24 f
.write_str(match *self {
25 ProcessStatus
::Idle
=> "Idle",
26 ProcessStatus
::Run
=> "Runnable",
27 ProcessStatus
::Sleep
=> "Sleeping",
28 ProcessStatus
::Stop
=> "Stopped",
29 ProcessStatus
::Zombie
=> "Zombie",
35 /// Enum describing the different status of a thread.
36 #[derive(Clone, Debug, PartialEq, Eq)]
37 pub enum ThreadStatus
{
38 /// Thread is running normally.
40 /// Thread is stopped.
42 /// Thread is waiting normally.
44 /// Thread is in an uninterruptible wait
46 /// Thread is halted at a clean point.
52 impl From
<i32> for ThreadStatus
{
53 fn from(status
: i32) -> ThreadStatus
{
55 1 => ThreadStatus
::Running
,
56 2 => ThreadStatus
::Stopped
,
57 3 => ThreadStatus
::Waiting
,
58 4 => ThreadStatus
::Uninterruptible
,
59 5 => ThreadStatus
::Halted
,
60 x
=> ThreadStatus
::Unknown(x
),
66 /// Used to display `ThreadStatus`.
67 pub fn to_string(&self) -> &str {
69 ThreadStatus
::Running
=> "Running",
70 ThreadStatus
::Stopped
=> "Stopped",
71 ThreadStatus
::Waiting
=> "Waiting",
72 ThreadStatus
::Uninterruptible
=> "Uninterruptible",
73 ThreadStatus
::Halted
=> "Halted",
74 ThreadStatus
::Unknown(_
) => "Unknown",
79 impl fmt
::Display
for ThreadStatus
{
80 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
81 write
!(f
, "{}", self.to_string())