Skip to content

Commit 92c5172

Browse files
committed
Impl From<uint32_t> for ProcFDType
1 parent 0f21ce8 commit 92c5172

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/libproc/proc_pid.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -603,34 +603,36 @@ pub struct ProcFDInfo {
603603
pub enum ProcFDType {
604604
/// AppleTalk
605605
ATalk = 0,
606-
/// vnode
606+
/// Vnode
607607
VNode = 1,
608-
/// socket
608+
/// Socket
609609
Socket = 2,
610610
/// POSIX shared memory
611611
PSHM = 3,
612612
/// POSIX semaphore
613613
PSEM = 4,
614-
/// kqueue
614+
/// Kqueue
615615
KQueue = 5,
616-
/// pipe
616+
/// Pipe
617617
Pipe = 6,
618618
/// FSEvents
619-
FSEvents = 7
619+
FSEvents = 7,
620+
/// Unknown
621+
Unknown,
620622
}
621623

622-
impl ProcFDType {
623-
pub fn from(value: uint32_t) -> Option<ProcFDType> {
624+
impl From<uint32_t> for ProcFDType {
625+
fn from(value: uint32_t) -> ProcFDType {
624626
match value {
625-
0 => Some(ProcFDType::ATalk ),
626-
1 => Some(ProcFDType::VNode ),
627-
2 => Some(ProcFDType::Socket ),
628-
3 => Some(ProcFDType::PSHM ),
629-
4 => Some(ProcFDType::PSEM ),
630-
5 => Some(ProcFDType::KQueue ),
631-
6 => Some(ProcFDType::Pipe ),
632-
7 => Some(ProcFDType::FSEvents),
633-
_ => None
627+
0 => ProcFDType::ATalk ,
628+
1 => ProcFDType::VNode ,
629+
2 => ProcFDType::Socket ,
630+
3 => ProcFDType::PSHM ,
631+
4 => ProcFDType::PSEM ,
632+
5 => ProcFDType::KQueue ,
633+
6 => ProcFDType::Pipe ,
634+
7 => ProcFDType::FSEvents,
635+
_ => ProcFDType::Unknown ,
634636
}
635637
}
636638
}

0 commit comments

Comments
 (0)