pub struct Metadata(/* private fields */);
Expand description
Metadata information about a file.
This structure is returned from themetadata
orsymlink_metadata
function or method and represents knownmetadata about a file such as its permissions, size, modificationtimes, etc.
Implementations§
Source§implMetadata
implMetadata
1.0.0 ·Sourcepub fnis_dir(&self) ->bool
pub fnis_dir(&self) ->bool
Returnstrue
if this metadata is for a directory. Theresult is mutually exclusive to the result ofMetadata::is_file
, and will be false for symlink metadataobtained fromsymlink_metadata
.
§Examples
1.0.0 ·Sourcepub fnis_file(&self) ->bool
pub fnis_file(&self) ->bool
Returnstrue
if this metadata is for a regular file. Theresult is mutually exclusive to the result ofMetadata::is_dir
, and will be false for symlink metadataobtained fromsymlink_metadata
.
When the goal is simply to read from (or write to) the source, the mostreliable way to test the source can be read (or written to) is to openit. Only usingis_file
can break workflows likediff <( prog_a )
ona Unix-like system for example. SeeFile::open
orOpenOptions::open
for more information.
§Examples
1.58.0 ·Sourcepub fnis_symlink(&self) ->bool
pub fnis_symlink(&self) ->bool
Returnstrue
if this metadata is for a symbolic link.
§Examples
1.0.0 ·Sourcepub fnlen(&self) ->u64
pub fnlen(&self) ->u64
Returns the size of the file, in bytes, this metadata is for.
§Examples
1.0.0 ·Sourcepub fnpermissions(&self) ->Permissions
pub fnpermissions(&self) ->Permissions
Returns the permissions of the file this metadata is for.
§Examples
1.10.0 ·Sourcepub fnmodified(&self) ->Result<SystemTime>
pub fnmodified(&self) ->Result<SystemTime>
Returns the last modification time listed in this metadata.
The returned value corresponds to themtime
field ofstat
on Unixplatforms and theftLastWriteTime
field on Windows platforms.
§Errors
This field might not be available on all platforms, and will return anErr
on platforms where it is not available.
§Examples
1.10.0 ·Sourcepub fnaccessed(&self) ->Result<SystemTime>
pub fnaccessed(&self) ->Result<SystemTime>
Returns the last access time of this metadata.
The returned value corresponds to theatime
field ofstat
on Unixplatforms and theftLastAccessTime
field on Windows platforms.
Note that not all platforms will keep this field update in a file’smetadata, for example Windows has an option to disable updating thistime when files are accessed and Linux similarly hasnoatime
.
§Errors
This field might not be available on all platforms, and will return anErr
on platforms where it is not available.
§Examples
1.10.0 ·Sourcepub fncreated(&self) ->Result<SystemTime>
pub fncreated(&self) ->Result<SystemTime>
Returns the creation time listed in this metadata.
The returned value corresponds to thebtime
field ofstatx
onLinux kernel starting from to 4.11, thebirthtime
field ofstat
on otherUnix platforms, and theftCreationTime
field on Windows platforms.
§Errors
This field might not be available on all platforms, and will return anErr
on platforms or filesystems where it is not available.
§Examples
Trait Implementations§
1.1.0 ·Source§implMetadataExt forMetadata
Available onApple only.
implMetadataExt forMetadata
Source§fnas_raw_stat(&self) -> &stat
fnas_raw_stat(&self) -> &stat
stat
structure which containsthe raw information returned by the OS.Read morefnst_dev(&self) ->u64
fnst_ino(&self) ->u64
fnst_mode(&self) ->u32
fnst_nlink(&self) ->u64
fnst_uid(&self) ->u32
fnst_gid(&self) ->u32
fnst_rdev(&self) ->u64
fnst_size(&self) ->u64
fnst_atime(&self) ->i64
fnst_atime_nsec(&self) ->i64
fnst_mtime(&self) ->i64
fnst_mtime_nsec(&self) ->i64
fnst_ctime(&self) ->i64
fnst_ctime_nsec(&self) ->i64
fnst_birthtime(&self) ->i64
fnst_birthtime_nsec(&self) ->i64
fnst_blksize(&self) ->u64
fnst_blocks(&self) ->u64
fnst_gen(&self) ->u32
fnst_flags(&self) ->u32
fnst_lspare(&self) ->u32
1.1.0 ·Source§implMetadataExt forMetadata
Available onUnix only.
implMetadataExt forMetadata
Source§fnatime(&self) ->i64
fnatime(&self) ->i64
Source§fnatime_nsec(&self) ->i64
fnatime_nsec(&self) ->i64
Source§fnmtime(&self) ->i64
fnmtime(&self) ->i64
Source§fnmtime_nsec(&self) ->i64
fnmtime_nsec(&self) ->i64
Source§fnctime(&self) ->i64
fnctime(&self) ->i64
Source§fnctime_nsec(&self) ->i64
fnctime_nsec(&self) ->i64
1.1.0 ·Source§implMetadataExt forMetadata
Available onLinux only.
implMetadataExt forMetadata
Source§fnas_raw_stat(&self) -> &stat
fnas_raw_stat(&self) -> &stat
stat
structure which containsthe raw information returned by the OS.Read moreSource§fnst_rdev(&self) ->u64
fnst_rdev(&self) ->u64
Source§fnst_size(&self) ->u64
fnst_size(&self) ->u64
Source§fnst_atime(&self) ->i64
fnst_atime(&self) ->i64
Source§fnst_atime_nsec(&self) ->i64
fnst_atime_nsec(&self) ->i64
Source§fnst_mtime(&self) ->i64
fnst_mtime(&self) ->i64
Source§fnst_mtime_nsec(&self) ->i64
fnst_mtime_nsec(&self) ->i64
Source§fnst_ctime(&self) ->i64
fnst_ctime(&self) ->i64
Source§fnst_ctime_nsec(&self) ->i64
fnst_ctime_nsec(&self) ->i64
Source§fnst_blksize(&self) ->u64
fnst_blksize(&self) ->u64
Source§implMetadataExt forMetadata
Available onWASI only.
implMetadataExt forMetadata
Source§fndev(&self) ->u64
fndev(&self) ->u64
wasi_ext
#71213)st_dev
field of the internalfilestat_t
Source§fnino(&self) ->u64
fnino(&self) ->u64
wasi_ext
#71213)st_ino
field of the internalfilestat_t
Source§fnnlink(&self) ->u64
fnnlink(&self) ->u64
wasi_ext
#71213)st_nlink
field of the internalfilestat_t
Source§fnsize(&self) ->u64
fnsize(&self) ->u64
wasi_ext
#71213)st_size
field of the internalfilestat_t
Source§fnatim(&self) ->u64
fnatim(&self) ->u64
wasi_ext
#71213)st_atim
field of the internalfilestat_t
1.1.0 ·Source§implMetadataExt forMetadata
Available onWindows only.
implMetadataExt forMetadata
Source§fnfile_attributes(&self) ->u32
fnfile_attributes(&self) ->u32
dwFileAttributes
field of this metadata.Read moreSource§fncreation_time(&self) ->u64
fncreation_time(&self) ->u64
ftCreationTime
field of this metadata.Read moreSource§fnlast_access_time(&self) ->u64
fnlast_access_time(&self) ->u64
ftLastAccessTime
field of this metadata.Read moreSource§fnlast_write_time(&self) ->u64
fnlast_write_time(&self) ->u64
ftLastWriteTime
field of this metadata.Read moreSource§fnvolume_serial_number(&self) ->Option<u32>
fnvolume_serial_number(&self) ->Option<u32>
windows_by_handle
#63010)dwVolumeSerialNumber
field of thismetadata.Read moreSource§fnnumber_of_links(&self) ->Option<u32>
fnnumber_of_links(&self) ->Option<u32>
windows_by_handle
#63010)nNumberOfLinks
field of thismetadata.Read more