starnix_core/vfs/
wd_number.rs1use starnix_syscalls::{SyscallArg, SyscallResult};
6use std::fmt;
7use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
8
9#[derive(
13 Hash,
14 PartialEq,
15 Eq,
16 PartialOrd,
17 Ord,
18 Debug,
19 Copy,
20 Clone,
21 IntoBytes,
22 KnownLayout,
23 FromBytes,
24 Immutable,
25)]
26#[repr(transparent)]
27pub struct WdNumber(i32);
28
29impl WdNumber {
30 pub fn from_raw(n: i32) -> WdNumber {
31 WdNumber(n)
32 }
33
34 pub fn raw(&self) -> i32 {
35 self.0
36 }
37}
38
39impl std::convert::From<WdNumber> for SyscallResult {
40 fn from(value: WdNumber) -> Self {
41 value.raw().into()
42 }
43}
44
45impl std::convert::From<SyscallArg> for WdNumber {
46 fn from(value: SyscallArg) -> Self {
47 WdNumber::from_raw(value.into())
48 }
49}
50
51impl fmt::Display for WdNumber {
52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53 write!(f, "wd({})", self.0)
54 }
55}