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
sourceimpl Metadata
impl Metadata
sourcepub fn file_type(&self) -> FileType
pub fn file_type(&self) -> FileType
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
pub fn is_dir(&self) -> bool
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
pub fn is_file(&self) -> bool
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
pub fn len(&self) -> u64
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
pub fn permissions(&self) -> Permissions
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>
pub fn modified(&self) -> Result<SystemTime>
sourcepub fn accessed(&self) -> Result<SystemTime>
pub fn accessed(&self) -> Result<SystemTime>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnwindSafe for Metadata
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more