1 #![stable(feature = "metadata_ext", since = "1.1.0")] 2 3 use crate::fs::Metadata; 4 use crate::sys_common::AsInner; 5 6 #[allow(deprecated)] 7 use crate::os::netbsd::raw; 8 9 /// OS-specific extensions to [`fs::Metadata`]. 10 /// 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. 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")] 21 #[rustc_deprecated( 22 since = "1.8.0", 23 reason = "deprecated in favor of the accessor \ 24 methods of this trait" 25 )] 26 #[allow(deprecated)] as_raw_stat(&self) -> &raw::stat27 fn as_raw_stat(&self) -> &raw::stat; 28 29 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_dev(&self) -> u6430 fn st_dev(&self) -> u64; 31 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_ino(&self) -> u6432 fn st_ino(&self) -> u64; 33 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_mode(&self) -> u3234 fn st_mode(&self) -> u32; 35 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_nlink(&self) -> u6436 fn st_nlink(&self) -> u64; 37 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_uid(&self) -> u3238 fn st_uid(&self) -> u32; 39 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_gid(&self) -> u3240 fn st_gid(&self) -> u32; 41 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_rdev(&self) -> u6442 fn st_rdev(&self) -> u64; 43 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_size(&self) -> u6444 fn st_size(&self) -> u64; 45 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_atime(&self) -> i6446 fn st_atime(&self) -> i64; 47 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_atime_nsec(&self) -> i6448 fn st_atime_nsec(&self) -> i64; 49 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_mtime(&self) -> i6450 fn st_mtime(&self) -> i64; 51 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_mtime_nsec(&self) -> i6452 fn st_mtime_nsec(&self) -> i64; 53 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_ctime(&self) -> i6454 fn st_ctime(&self) -> i64; 55 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_ctime_nsec(&self) -> i6456 fn st_ctime_nsec(&self) -> i64; 57 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_birthtime(&self) -> i6458 fn st_birthtime(&self) -> i64; 59 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_birthtime_nsec(&self) -> i6460 fn st_birthtime_nsec(&self) -> i64; 61 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_blksize(&self) -> u6462 fn st_blksize(&self) -> u64; 63 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_blocks(&self) -> u6464 fn st_blocks(&self) -> u64; 65 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_flags(&self) -> u3266 fn st_flags(&self) -> u32; 67 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_gen(&self) -> u3268 fn st_gen(&self) -> u32; 69 } 70 71 #[stable(feature = "metadata_ext", since = "1.1.0")] 72 impl MetadataExt for Metadata { 73 #[allow(deprecated)] as_raw_stat(&self) -> &raw::stat74 fn as_raw_stat(&self) -> &raw::stat { 75 unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } 76 } st_dev(&self) -> u6477 fn st_dev(&self) -> u64 { 78 self.as_inner().as_inner().st_dev as u64 79 } st_ino(&self) -> u6480 fn st_ino(&self) -> u64 { 81 self.as_inner().as_inner().st_ino as u64 82 } st_mode(&self) -> u3283 fn st_mode(&self) -> u32 { 84 self.as_inner().as_inner().st_mode as u32 85 } st_nlink(&self) -> u6486 fn st_nlink(&self) -> u64 { 87 self.as_inner().as_inner().st_nlink as u64 88 } st_uid(&self) -> u3289 fn st_uid(&self) -> u32 { 90 self.as_inner().as_inner().st_uid as u32 91 } st_gid(&self) -> u3292 fn st_gid(&self) -> u32 { 93 self.as_inner().as_inner().st_gid as u32 94 } st_rdev(&self) -> u6495 fn st_rdev(&self) -> u64 { 96 self.as_inner().as_inner().st_rdev as u64 97 } st_size(&self) -> u6498 fn st_size(&self) -> u64 { 99 self.as_inner().as_inner().st_size as u64 100 } st_atime(&self) -> i64101 fn st_atime(&self) -> i64 { 102 self.as_inner().as_inner().st_atime as i64 103 } st_atime_nsec(&self) -> i64104 fn st_atime_nsec(&self) -> i64 { 105 self.as_inner().as_inner().st_atimensec as i64 106 } st_mtime(&self) -> i64107 fn st_mtime(&self) -> i64 { 108 self.as_inner().as_inner().st_mtime as i64 109 } st_mtime_nsec(&self) -> i64110 fn st_mtime_nsec(&self) -> i64 { 111 self.as_inner().as_inner().st_mtimensec as i64 112 } st_ctime(&self) -> i64113 fn st_ctime(&self) -> i64 { 114 self.as_inner().as_inner().st_ctime as i64 115 } st_ctime_nsec(&self) -> i64116 fn st_ctime_nsec(&self) -> i64 { 117 self.as_inner().as_inner().st_ctimensec as i64 118 } st_birthtime(&self) -> i64119 fn st_birthtime(&self) -> i64 { 120 self.as_inner().as_inner().st_birthtime as i64 121 } st_birthtime_nsec(&self) -> i64122 fn st_birthtime_nsec(&self) -> i64 { 123 self.as_inner().as_inner().st_birthtimensec as i64 124 } st_blksize(&self) -> u64125 fn st_blksize(&self) -> u64 { 126 self.as_inner().as_inner().st_blksize as u64 127 } st_blocks(&self) -> u64128 fn st_blocks(&self) -> u64 { 129 self.as_inner().as_inner().st_blocks as u64 130 } st_gen(&self) -> u32131 fn st_gen(&self) -> u32 { 132 self.as_inner().as_inner().st_gen as u32 133 } st_flags(&self) -> u32134 fn st_flags(&self) -> u32 { 135 self.as_inner().as_inner().st_flags as u32 136 } 137 } 138