1 #![stable(feature = "metadata_ext", since = "1.1.0")]
3 use crate::fs::Metadata;
4 use crate::sys_common::AsInner;
7 use crate::os::netbsd::raw;
9 /// OS-specific extensions to [`fs::Metadata`].
11 /// [`fs::Metadata`]: crate::fs::Metadata
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.
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")]
23 note = "deprecated in favor of the accessor \
24 methods of this trait"
27 fn as_raw_stat(&self) -> &raw::stat;
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;
71 #[stable(feature = "metadata_ext", since = "1.1.0")]
72 impl MetadataExt for Metadata {
74 fn as_raw_stat(&self) -> &raw::stat {
75 unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) }
77 fn st_dev(&self) -> u64 {
78 self.as_inner().as_inner().st_dev as u64
80 fn st_ino(&self) -> u64 {
81 self.as_inner().as_inner().st_ino as u64
83 fn st_mode(&self) -> u32 {
84 self.as_inner().as_inner().st_mode as u32
86 fn st_nlink(&self) -> u64 {
87 self.as_inner().as_inner().st_nlink as u64
89 fn st_uid(&self) -> u32 {
90 self.as_inner().as_inner().st_uid as u32
92 fn st_gid(&self) -> u32 {
93 self.as_inner().as_inner().st_gid as u32
95 fn st_rdev(&self) -> u64 {
96 self.as_inner().as_inner().st_rdev as u64
98 fn st_size(&self) -> u64 {
99 self.as_inner().as_inner().st_size as u64
101 fn st_atime(&self) -> i64 {
102 self.as_inner().as_inner().st_atime as i64
104 fn st_atime_nsec(&self) -> i64 {
105 self.as_inner().as_inner().st_atimensec as i64
107 fn st_mtime(&self) -> i64 {
108 self.as_inner().as_inner().st_mtime as i64
110 fn st_mtime_nsec(&self) -> i64 {
111 self.as_inner().as_inner().st_mtimensec as i64
113 fn st_ctime(&self) -> i64 {
114 self.as_inner().as_inner().st_ctime as i64
116 fn st_ctime_nsec(&self) -> i64 {
117 self.as_inner().as_inner().st_ctimensec as i64
119 fn st_birthtime(&self) -> i64 {
120 self.as_inner().as_inner().st_birthtime as i64
122 fn st_birthtime_nsec(&self) -> i64 {
123 self.as_inner().as_inner().st_birthtimensec as i64
125 fn st_blksize(&self) -> u64 {
126 self.as_inner().as_inner().st_blksize as u64
128 fn st_blocks(&self) -> u64 {
129 self.as_inner().as_inner().st_blocks as u64
131 fn st_gen(&self) -> u32 {
132 self.as_inner().as_inner().st_gen as u32
134 fn st_flags(&self) -> u32 {
135 self.as_inner().as_inner().st_flags as u32