logo
pub struct Metadata { /* private fields */ }
Expand description

Metadata for a file or directory.

Metadata is returned by metadata and symlink_metadata.

This type is a re-export of std::fs::Metadata.

Implementations

Returns the file type from this metadata.

Examples
use async_std::fs;

let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.file_type());

Returns true if this metadata is for a regular directory.

If this metadata is for a symbolic link, this method returns false.

Examples
use async_std::fs;

let metadata = fs::metadata(".").await?;
println!("{:?}", metadata.is_dir());

Returns true if this metadata is for a regular file.

If this metadata is for a symbolic link, this method returns false.

Examples
use async_std::fs;

let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.is_file());

Returns the file size in bytes.

Examples
use async_std::fs;

let metadata = fs::metadata("a.txt").await?;
println!("{}", metadata.len());

Returns the permissions from this metadata.

Examples
use async_std::fs;

let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.permissions());

Returns the last modification time.

Errors

This data may not be available on all platforms, in which case an error will be returned.

Examples
use async_std::fs;

let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.modified());

Returns the last access time.

Errors

This data may not be available on all platforms, in which case an error will be returned.

Examples
use async_std::fs;

let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.accessed());

Returns the creation time.

Errors

This data may not be available on all platforms, in which case an error will be returned.

Examples
use async_std::fs;

let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.created());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.