pub struct Metadata { /* private fields */ }Available on crate feature
default and non-target_os=unknown only.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§
Source§impl Metadata
impl Metadata
Sourcepub fn file_type(&self) -> FileType
Available on crate feature docs only.
pub fn file_type(&self) -> FileType
docs only.Returns the file type from this metadata.
§Examples
use async_std::fs;
let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.file_type());Sourcepub fn is_dir(&self) -> bool
Available on crate feature docs only.
pub fn is_dir(&self) -> bool
docs only.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());Sourcepub fn is_file(&self) -> bool
Available on crate feature docs only.
pub fn is_file(&self) -> bool
docs only.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());Sourcepub fn len(&self) -> u64
Available on crate feature docs only.
pub fn len(&self) -> u64
docs only.Returns the file size in bytes.
§Examples
use async_std::fs;
let metadata = fs::metadata("a.txt").await?;
println!("{}", metadata.len());Sourcepub fn permissions(&self) -> Permissions
Available on crate feature docs only.
pub fn permissions(&self) -> Permissions
docs only.Returns the permissions from this metadata.
§Examples
use async_std::fs;
let metadata = fs::metadata("a.txt").await?;
println!("{:?}", metadata.permissions());Sourcepub fn modified(&self) -> Result<SystemTime>
Available on crate feature docs only.
pub fn modified(&self) -> Result<SystemTime>
docs only.Sourcepub fn accessed(&self) -> Result<SystemTime>
Available on crate feature docs only.
pub fn accessed(&self) -> Result<SystemTime>
docs only.Sourcepub fn created(&self) -> Result<SystemTime>
Available on crate feature docs only.
pub fn created(&self) -> Result<SystemTime>
docs only.Trait Implementations§
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more