]>
Commit | Line | Data |
---|---|---|
7453a54e SL |
1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
2 | ||
532ac7d7 XL |
3 | use crate::fs::Metadata; |
4 | use crate::sys_common::AsInner; | |
7453a54e SL |
5 | |
6 | #[allow(deprecated)] | |
532ac7d7 | 7 | use crate::os::freebsd::raw; |
7453a54e | 8 | |
83c7162d XL |
9 | /// OS-specific extensions to [`fs::Metadata`]. |
10 | /// | |
11 | /// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html | |
7453a54e SL |
12 | #[stable(feature = "metadata_ext", since = "1.1.0")] |
13 | pub trait MetadataExt { | |
14 | /// Gain a reference to the underlying `stat` structure which contains | |
15 | /// the raw information returned by the OS. | |
16 | /// | |
17 | /// The contents of the returned `stat` are **not** consistent across | |
18 | /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the | |
19 | /// cross-Unix abstractions contained within the raw stat. | |
20 | #[stable(feature = "metadata_ext", since = "1.1.0")] | |
60c5eb7d XL |
21 | #[rustc_deprecated( |
22 | since = "1.8.0", | |
23 | reason = "deprecated in favor of the accessor \ | |
24 | methods of this trait" | |
25 | )] | |
7453a54e SL |
26 | #[allow(deprecated)] |
27 | fn as_raw_stat(&self) -> &raw::stat; | |
28 | ||
29 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
30 | fn st_dev(&self) -> u64; | |
31 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
32 | fn st_ino(&self) -> u64; | |
33 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
34 | fn st_mode(&self) -> u32; | |
35 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
36 | fn st_nlink(&self) -> u64; | |
37 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
38 | fn st_uid(&self) -> u32; | |
39 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
40 | fn st_gid(&self) -> u32; | |
41 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
42 | fn st_rdev(&self) -> u64; | |
43 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
44 | fn st_size(&self) -> u64; | |
45 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
46 | fn st_atime(&self) -> i64; | |
47 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
48 | fn st_atime_nsec(&self) -> i64; | |
49 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
50 | fn st_mtime(&self) -> i64; | |
51 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
52 | fn st_mtime_nsec(&self) -> i64; | |
53 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
54 | fn st_ctime(&self) -> i64; | |
55 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
56 | fn st_ctime_nsec(&self) -> i64; | |
57 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
58 | fn st_birthtime(&self) -> i64; | |
59 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
60 | fn st_birthtime_nsec(&self) -> i64; | |
61 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
62 | fn st_blksize(&self) -> u64; | |
63 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
64 | fn st_blocks(&self) -> u64; | |
65 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
66 | fn st_flags(&self) -> u32; | |
67 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
68 | fn st_gen(&self) -> u32; | |
69 | #[stable(feature = "metadata_ext2", since = "1.8.0")] | |
70 | fn st_lspare(&self) -> u32; | |
71 | } | |
72 | ||
73 | #[stable(feature = "metadata_ext", since = "1.1.0")] | |
74 | impl MetadataExt for Metadata { | |
75 | #[allow(deprecated)] | |
76 | fn as_raw_stat(&self) -> &raw::stat { | |
60c5eb7d | 77 | unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } |
7453a54e SL |
78 | } |
79 | fn st_dev(&self) -> u64 { | |
80 | self.as_inner().as_inner().st_dev as u64 | |
81 | } | |
82 | fn st_ino(&self) -> u64 { | |
83 | self.as_inner().as_inner().st_ino as u64 | |
84 | } | |
85 | fn st_mode(&self) -> u32 { | |
86 | self.as_inner().as_inner().st_mode as u32 | |
87 | } | |
88 | fn st_nlink(&self) -> u64 { | |
89 | self.as_inner().as_inner().st_nlink as u64 | |
90 | } | |
91 | fn st_uid(&self) -> u32 { | |
92 | self.as_inner().as_inner().st_uid as u32 | |
93 | } | |
94 | fn st_gid(&self) -> u32 { | |
95 | self.as_inner().as_inner().st_gid as u32 | |
96 | } | |
97 | fn st_rdev(&self) -> u64 { | |
98 | self.as_inner().as_inner().st_rdev as u64 | |
99 | } | |
100 | fn st_size(&self) -> u64 { | |
101 | self.as_inner().as_inner().st_size as u64 | |
102 | } | |
103 | fn st_atime(&self) -> i64 { | |
104 | self.as_inner().as_inner().st_atime as i64 | |
105 | } | |
106 | fn st_atime_nsec(&self) -> i64 { | |
107 | self.as_inner().as_inner().st_atime_nsec as i64 | |
108 | } | |
109 | fn st_mtime(&self) -> i64 { | |
110 | self.as_inner().as_inner().st_mtime as i64 | |
111 | } | |
112 | fn st_mtime_nsec(&self) -> i64 { | |
113 | self.as_inner().as_inner().st_mtime_nsec as i64 | |
114 | } | |
115 | fn st_ctime(&self) -> i64 { | |
116 | self.as_inner().as_inner().st_ctime as i64 | |
117 | } | |
118 | fn st_ctime_nsec(&self) -> i64 { | |
119 | self.as_inner().as_inner().st_ctime_nsec as i64 | |
120 | } | |
121 | fn st_birthtime(&self) -> i64 { | |
122 | self.as_inner().as_inner().st_birthtime as i64 | |
123 | } | |
124 | fn st_birthtime_nsec(&self) -> i64 { | |
125 | self.as_inner().as_inner().st_birthtime_nsec as i64 | |
126 | } | |
127 | fn st_blksize(&self) -> u64 { | |
128 | self.as_inner().as_inner().st_blksize as u64 | |
129 | } | |
130 | fn st_blocks(&self) -> u64 { | |
131 | self.as_inner().as_inner().st_blocks as u64 | |
132 | } | |
133 | fn st_gen(&self) -> u32 { | |
134 | self.as_inner().as_inner().st_gen as u32 | |
135 | } | |
136 | fn st_flags(&self) -> u32 { | |
137 | self.as_inner().as_inner().st_flags as u32 | |
138 | } | |
139 | fn st_lspare(&self) -> u32 { | |
140 | self.as_inner().as_inner().st_lspare as u32 | |
141 | } | |
142 | } |