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::illumos::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 methods of this trait" 24 )] 25 #[allow(deprecated)] as_raw_stat(&self) -> &raw::stat26 fn as_raw_stat(&self) -> &raw::stat; 27 28 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_dev(&self) -> u6429 fn st_dev(&self) -> u64; 30 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_ino(&self) -> u6431 fn st_ino(&self) -> u64; 32 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_mode(&self) -> u3233 fn st_mode(&self) -> u32; 34 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_nlink(&self) -> u6435 fn st_nlink(&self) -> u64; 36 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_uid(&self) -> u3237 fn st_uid(&self) -> u32; 38 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_gid(&self) -> u3239 fn st_gid(&self) -> u32; 40 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_rdev(&self) -> u6441 fn st_rdev(&self) -> u64; 42 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_size(&self) -> u6443 fn st_size(&self) -> u64; 44 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_atime(&self) -> i6445 fn st_atime(&self) -> i64; 46 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_atime_nsec(&self) -> i6447 fn st_atime_nsec(&self) -> i64; 48 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_mtime(&self) -> i6449 fn st_mtime(&self) -> i64; 50 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_mtime_nsec(&self) -> i6451 fn st_mtime_nsec(&self) -> i64; 52 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_ctime(&self) -> i6453 fn st_ctime(&self) -> i64; 54 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_ctime_nsec(&self) -> i6455 fn st_ctime_nsec(&self) -> i64; 56 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_blksize(&self) -> u6457 fn st_blksize(&self) -> u64; 58 #[stable(feature = "metadata_ext2", since = "1.8.0")] st_blocks(&self) -> u6459 fn st_blocks(&self) -> u64; 60 } 61 62 #[stable(feature = "metadata_ext", since = "1.1.0")] 63 impl MetadataExt for Metadata { 64 #[allow(deprecated)] as_raw_stat(&self) -> &raw::stat65 fn as_raw_stat(&self) -> &raw::stat { 66 unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } 67 } st_dev(&self) -> u6468 fn st_dev(&self) -> u64 { 69 self.as_inner().as_inner().st_dev as u64 70 } st_ino(&self) -> u6471 fn st_ino(&self) -> u64 { 72 self.as_inner().as_inner().st_ino as u64 73 } st_mode(&self) -> u3274 fn st_mode(&self) -> u32 { 75 self.as_inner().as_inner().st_mode as u32 76 } st_nlink(&self) -> u6477 fn st_nlink(&self) -> u64 { 78 self.as_inner().as_inner().st_nlink as u64 79 } st_uid(&self) -> u3280 fn st_uid(&self) -> u32 { 81 self.as_inner().as_inner().st_uid as u32 82 } st_gid(&self) -> u3283 fn st_gid(&self) -> u32 { 84 self.as_inner().as_inner().st_gid as u32 85 } st_rdev(&self) -> u6486 fn st_rdev(&self) -> u64 { 87 self.as_inner().as_inner().st_rdev as u64 88 } st_size(&self) -> u6489 fn st_size(&self) -> u64 { 90 self.as_inner().as_inner().st_size as u64 91 } st_atime(&self) -> i6492 fn st_atime(&self) -> i64 { 93 self.as_inner().as_inner().st_atime as i64 94 } st_atime_nsec(&self) -> i6495 fn st_atime_nsec(&self) -> i64 { 96 self.as_inner().as_inner().st_atime_nsec as i64 97 } st_mtime(&self) -> i6498 fn st_mtime(&self) -> i64 { 99 self.as_inner().as_inner().st_mtime as i64 100 } st_mtime_nsec(&self) -> i64101 fn st_mtime_nsec(&self) -> i64 { 102 self.as_inner().as_inner().st_mtime_nsec as i64 103 } st_ctime(&self) -> i64104 fn st_ctime(&self) -> i64 { 105 self.as_inner().as_inner().st_ctime as i64 106 } st_ctime_nsec(&self) -> i64107 fn st_ctime_nsec(&self) -> i64 { 108 self.as_inner().as_inner().st_ctime_nsec as i64 109 } st_blksize(&self) -> u64110 fn st_blksize(&self) -> u64 { 111 self.as_inner().as_inner().st_blksize as u64 112 } st_blocks(&self) -> u64113 fn st_blocks(&self) -> u64 { 114 self.as_inner().as_inner().st_blocks as u64 115 } 116 } 117