use crate::io;
use crate::path::Path;
use crate::task::spawn_blocking;
pub async fn metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
let path = path.as_ref().to_owned();
spawn_blocking(move || std::fs::metadata(path)).await
}
cfg_not_docs! {
pub use std::fs::Metadata;
}
cfg_docs! {
use std::time::SystemTime;
use crate::fs::{FileType, Permissions};
#[derive(Clone, Debug)]
pub struct Metadata {
_private: (),
}
impl Metadata {
pub fn file_type(&self) -> FileType {
unreachable!("this impl only appears in the rendered docs")
}
pub fn is_dir(&self) -> bool {
unreachable!("this impl only appears in the rendered docs")
}
pub fn is_file(&self) -> bool {
unreachable!("this impl only appears in the rendered docs")
}
pub fn len(&self) -> u64 {
unreachable!("this impl only appears in the rendered docs")
}
pub fn permissions(&self) -> Permissions {
unreachable!("this impl only appears in the rendered docs")
}
pub fn modified(&self) -> io::Result<SystemTime> {
unreachable!("this impl only appears in the rendered docs")
}
pub fn accessed(&self) -> io::Result<SystemTime> {
unreachable!("this impl only appears in the rendered docs")
}
pub fn created(&self) -> io::Result<SystemTime> {
unreachable!("this impl only appears in the rendered docs")
}
}
}